How do I Call SMSFormatMessageCtl.FormatModuleMessage?

107 views Asked by At

I'm attempting to query the server for particular status messages and build the string format of them. The status message data doesn't contain the translated strings. They appear to be stored in srvmsgs.dll in the install directory for the console.

I see some "documentation" (proof that it exists, not help for using it) about the FormatModuleMessage method of SMSFormatMessageCtl. Sadly, there are no examples that I can find. This guy mentions that he has gotten it to work, but he doesn't provide details. In fact, I cannot even find the DLL referenced (FormatMessageCtl.dll) on my computer. StatView.EXE (the status message viewer app that comes with the client) exists, but running the dependency walker on it doesn't reveal any overt reference the desired .DLL.

Can this be done in VBScript or, preferably, PowerShell? I'm actually using Perl, but this is probably less common and nearly impossible to find meaningful code examples for. A working VBScript or PowerShell example would be a good place to start.

About Configuration Manager Component Status Messages” has an example, but I think it’s in C# or C++.

Any suggestions on how to accomplish this?

1

There are 1 answers

0
Tim Johnson On BEST ANSWER

I'm that guy. It's been 2 years, but I think the way I did it was that first I did a regsvr32.exe for the dll to register it, and then I just created an SMSFormatMessageCtl object through COM

For PowerShell that would be

New-Object -COMObject SMSFormatMessageCTL

For Perl, it's been even longer, but if I recall correctly, that would be

Win32::OLE->DispatchEx('SMSFormatMessageCtl');

Once you have the object you can call the FormatModuleMessage method, and don't forget the part about doing a bitwise OR of the Severity and MessageID from the WMI objects.