|
You have created the message files and compiled them with the "message compiler" (mc.exe)?
You are _really_ sure your DLL containing these messages is in the registry:
HKLM\System\Current...\Serives\Eventlog\Applications\MyFooApp
and that there is a REG_SZ or REG_EXPAND_SZ entry with the name EventMessageFile pointing to your message DLL?
If you are really, really sure this is OK, I think you have to elaborate.
|
|
|
|
|
First off,Thanks for the response---I appreciate any help you can offer.
I was going to post my code with my question, but I'm new to this board and didn't see an attachment box anywhere. Is it possible to upload small attachments?
I have compiled the message file using the MC.exe with several different parameters(every source I have found uses slightly different parameter). I then use RC.exe to create the .res file. I then use link.exe to create the DLL from the .res file. I'm not sure any of this is completely correct.
I use a CRegKey object(m_RegistryKey) in a wrapper class I wrote and call my member function below. I have tried #define MY_LOGGER_REG_PATH "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\Logger" and I still get the same description, Logger is just stored under Application instead of EventLog.
#define MY_LOGGER_REG_PATH "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Logger"
void LogRegisterMod::CreateRegKey()
{
// prevents re-creation of registry key if it already exists
// if(this->m_RegistryKey.Open(HKEY_LOCAL_MACHINE,MY_LOGGER_REG_PATH) != ERROR_SUCCESS)
{
// creates or opens(if key already exists) the registry key
this->m_RegistryKey.Create(HKEY_LOCAL_MACHINE, MY_LOGGER_REG_PATH);
// sets the type of event the log supports
this->m_RegistryKey.SetValue(EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE | EVENTLOG_ERROR_TYPE,"TypesSupported");
// sets the HD path to find the event message DLL/EXE
this->m_RegistryKey.SetValue("C:\\Data\\CodeRock\\CS499\\Logger\\LoggerMessage.dll","EventMessageFile");
// sets the number of catergories in the message DLL/EXE
this->m_RegistryKey.SetValue(1,"CategoryCount");
// closes the registry key
this->m_RegistryKey.Close();
}
}
This is my message file.
;/*********************************************************************
; Module Name: LoggerMessage.mc
; This will produce the Message DLL to be associated with the Logger event logging
;/*********************************************************************
;//*********************Catergory Section********************************
;// Catergory ID are 16-bit values
MessageIdTypedef=WORD
MessageId=1
Severity=Success
Facility=Application
SymbolicName=MSG_TEST
Language=English
Test
.
;//**********************Message Section********************************
;// Event ID's are 32-bit values
MessageIdTypedef=DWORD
MessageId=100
Severity=Informational
Facility=Application
SymbolicName=MSG_USERNAME
Language=English
Username:%1, Password %2
.
;//*************************End of File********************************
You can kill the revolutionary, but you can't kill the Revolution. (RATM & TOOL)
|
|
|
|
|
niverson wrote:
I have tried #define MY_LOGGER_REG_PATH "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\Logger" and I still get the same description
That is however how it's intended to be used. You should usually not add any keys to the Eventlog key (since that in fact is creating a new event log!), only its three existing subkeys.
What might be a problem for you, is that according to documentatin the EventMessageFile value must be of type REG_EXPAND_SZ. From your code it seems you're using a plain REG_SZ. This probably isn't a problem in your case since you're using hard-coded paths, but when given the choice to do it "right".
Another thing to look out for is that (again if my memory serves me) is that you need to add the value ParameterMessageFile (also REG_EXPAND_SZ) for event messages with replacement values. I think this is your current problem.
|
|
|
|
|
I have looked at the REG_EXPAND_SZ parameter before and that is used to expand %SystemRoot% to the local machines Root path. I think I have to find an API function to declare REG_EXPAND_SZ because the MFC function specifies REG_SZ automatically.
There are three message files that can be specified: ParameterMessageFile, CatergoryMessageFile, and EventMessageFile. I have added all three and pointed then to the same DLL. According to the books, the DLL can contain all three types in one file. My current DLL only has catergories and events. It gave me the same error message. I have looked at other event log registry values and some have all three specified, some have Category and Event, others have only event. I will try this again. The books say how important Logging is, but I haven't found a good example of source code that implements logging yet. As important as Logging is, VS 6.0 doesn't have a Message compiler integrated. Logging looks like it was added as an afterthought.
Nate
You can kill the revolutionary, but you can't kill the Revolution. (RATM & TOOL)
|
|
|
|
|
I'm trying to get the strings of my CMenu, but it returns an error, why is this?
|
|
|
|
|
|
Can anybody help me out here please,
By default CRecordset Creates a RFX_Date in it's header. This Only supports CTime. How Can I save My COleDateTime to Access without converting to CTime(I don't know why CTime was ever created). I read an artical a while ago About this but I can't seem to find it again.
Hey if nobody knows, Well Somebody will know sometime!!!
|
|
|
|
|
Suppose I code such a very simple code:
void main()
{
printf("main is at 0x%p\n", main);
}
I get a result:
main is at 0x0040100F
But if I hover the cursor on the variable main while debugging, VC++ tells me, the address of main at 0x00401030.
So how can I printf the actual address of main (0x00401030) ??
Here's the assembly code:
@ILT+10(_main):
0040100F E9 1C 00 00 00 jmp main (00401030)
5: void main()
6: {
00401030 55 push ebp
00401031 8B EC mov ebp,esp
00401033 83 EC 48 sub esp,48h
00401036 53 push ebx
00401037 56 push esi
00401038 57 push edi
00401039 8D 7D B8 lea edi,[ebp-48h]
0040103C B9 12 00 00 00 mov ecx,12h
00401041 B8 CC CC CC CC mov eax,0CCCCCCCCh
00401046 F3 AB rep stos dword ptr [edi]
Maxwell Chen
People say "No news is good news". Then, no code is good code!?
|
|
|
|
|
When you run in debugger mode, some of the breakpoint code is also inserted and thus main() gets displaced.
Nish
The posting stats are now in PDF:-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
Updated - May 04th, Saturday
|
|
|
|
|
Yes, but I was printing the address while in debugging mode,
it should still have printed the address that maps to the machine code, but it did not!
Please take a look at the assembly and machine code at the end of the original message again. The output told me the address of
@ILT+10(_main)
but not the address of
5: void main()<br>6: {<br>00401030 55
That's what I am curious about.
Maxwell Chen
People say "No news is good news". Then, no code is good code!?
|
|
|
|
|
In an ATL COM Server,how can I load a conventional DLL?
|
|
|
|
|
Hi,
If I understand you correct, do you want to load a DLL at runtime? If so the look at the 'LoadLibrary' API for non MFC projects and AfxLoadLibrary for MFC projects....
else if at compile time then use the static library *.lib and the required header file
|
|
|
|
|
I have an MFC Extension DLL implemented in my program. It is a simple modless dialog. Everything works fine in Debug but when I go to release and run it I get an Assertion right when I try to set a variable in the DLL class from the calling app.
I can post some code it need be, but has anyone seen this. And if so, what are some of the ways that you have fixed it.
Thanks in advance
***********************
Tony Fontenot
Recreational Solutions
tony@recsolutions.com
***********************
|
|
|
|
|
Sorry all. I figured it out. I copied the wrong dll.
***********************
Tony Fontenot
Recreational Solutions
tony@recsolutions.com
***********************
|
|
|
|
|
CString strFullName
gethostbyname(const char *name)
This won't compile under Unicode in VC 7, How should i fix this?
gethostbyname(strFullName);
Thanks
- Matt Newman / Windows XP Activist
-Sonork ID: 100.11179
01001001 00100000 01010000 01100001 01100100 00100000 01001101 01111001 00100000 01010000 01101111 01110011 01110100 00100000 01000011 01101111 01110101 01101110 01110100
|
|
|
|
|
CString only converts to LPCTSTR, which is a Unicode string when building for Unicode. The quickest way is to use an ATL conversion macro:
#include <atlconv.h>
{
USES_CONVERSION;
gethostbyname ( T2CA((LPCTSTR) strFullName) );
}
--Mike--
Buy me stuff! (Link fixed now)
Like the Google toolbar? Then check out UltraBar, with more features & customizable search engines!
My really out-of-date homepage
Big fan of Alyson Hannigan and Jamie Salé.
Sonork - 100.10414 AcidHelm
|
|
|
|
|
Michael Dunn wrote:
{
USES_CONVERSION;
gethostbyname ( T2CA((LPCTSTR) strFullName) );
}
Where do I put this?
if I replace the original with this it just makes it unreadable characters
- Matt Newman / Windows XP Activist
-Sonork ID: 100.11179
01001001 00100000 01010000 01100001 01100100 00100000 01001101 01111001 00100000 01010000 01101111 01110011 01110100 00100000 01000011 01101111 01110101 01101110 01110100
|
|
|
|
|
|
Sorry about the delay I was gone this weekend
CString strTemp;
int item = 0;
struct hostent *host;
struct in_addr *ptr;
DWORD dwScope = RESOURCE_CONTEXT;
NETRESOURCE *NetResource = NULL;
HANDLE hEnum;
WNetOpenEnum(dwScope, NULL, NULL, NULL, &hEnum);
WSADATA wsaData;
WSAStartup(MAKEWORD(1,1),&wsaData);
if (hEnum)
{
DWORD Count = 0xFFFFFFFF;
DWORD BufferSize = 2048;
LPVOID Buffer = new char[2048];
WNetEnumResource(hEnum, &Count, Buffer, &BufferSize);
NetResource = (NETRESOURCE*)Buffer;
char szHostName[200];
for (unsigned int i = 0; i < BufferSize/sizeof(NETRESOURCE); i++, NetResource++)
{
if (NetResource->dwUsage == RESOURCEUSAGE_CONTAINER && NetResource->dwType == RESOURCETYPE_ANY)
{
if (NetResource->lpRemoteName)
{
CString strFullName = NetResource->lpRemoteName;
char buf[512];
if (0 == strFullName.Left(2).Compare(_T("\\\\")))
strFullName = strFullName.Right(strFullName.GetLength()-2);
<code>host = gethostbyname(strFullName));</code>
if (!host) continue;
ptr = (struct in_addr *) host->h_addr_list[0];
sprintf(buf, "%d.%d.%d.%d", ptr->S_un.S_un_b.s_b1,
ptr->S_un.S_un_b.s_b2, ptr->S_un.S_un_b.s_b3, ptr->S_un.S_un_b.s_b4);\
List->InsertItem(item++, strFullName, 0);
List->SetItemText(item - 1, 1, (LPTSTR)buf);
List->SetItemText(item - 1, 2, NetResource->lpComment);
}
}
}
This is the original code,
- Matt Newman / Windows XP Activist
-Sonork ID: 100.11179
01001001 00100000 01010000 01100001 01100100 00100000 01001101 01111001 00100000 01010000 01101111 01110011 01110100 00100000 01000011 01101111 01110101 01101110 01110100
|
|
|
|
|
Look at the function WideCharToMultiByte to convert the UNICODE string to a char*.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
This is basically a guess.
But you might try using WideCharToMultiByte to convert the unicode string to a normal string
Nish
The posting stats are now in PDF:-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
Updated - May 04th, Saturday
|
|
|
|
|
Here you go, no please tell me how to make it work.
It does not like my CList expression (and neither do I )
<br />
typedef struct <br />
{<br />
int data;<br />
int temp;<br />
<br />
}dataStructure;<br />
<br />
typedef CList <dataStructure,dataStructure> dataList;<br />
<br />
<code><br />
<br />
p.s thanks bracket tip
|
|
|
|
|
Coremn wrote:
typedef CList <<datastructure,datastructure>> dataList;
You should change that to this:
typedef CList <dataStructure,& dataStructure> dataList;
BTW, you can add the single < or > by using & lt; and & gt;, or excapsulate all of your code in between <PRE> and </PRE> tags.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
< broken record >
CList sucks. Use std::list instead
< /broken record >
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Agreed
|
|
|
|