|
-
October 22nd, 2002, 01:48 PM
#1
FormatMessage in ATL COM problem
I'm having a problem with FormatMessage in ATL COM object.
I have a basic ATL COM dll that has a message in its string table defined:
IDS_UPDATES_AVAILABLE - Some string with places to fill %1 type strings....
I'm trying to use FormatMessage API to retrieve and format this string, and I'm getting weird problems with it. Here is the code:
Code:
LPTSTR lpFinalMessage = NULL;
LPTSTR lpUpdateComments = NULL;
lpUpdateComments = _T("Some sort of string...");
DWORD dwRetVal = ::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_ARGUMENT_ARRAY, _Module.GetResourceInstance(), IDS_UPDATES_AVAILABLE, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpFinalMessage, 500, &lpUpdateComments);
DWORD dwErr = GetLastError();
Problem is: FormatMessage always returns 0, and error code doesn't make that much sense.
The way the code is above, error returned in 1813 - The specified resource type cannot be found in the image file. A) IDS string thingy is definately there (it wouldn't really compile otherwise), and B) I'm not specifying type anywhere - it is basic String Table. (By the way, changing next to last parameter from 500 to 0 or any other number doesn't change anything).
If I try to simplify - remove FORMAT_MESSAGE_FROM_HMODULE and pass NULL instead of _Module.GetResourceInstance(), I get error 87 - The parameter is incorrect.
Anyone has any idea what is going on???
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|