about eventlog

Akira Nakagawa matyapiro31 at gmail.com
Tue Dec 31 22:43:50 CST 2013


I examined the design of RegistereventSource().
The return value type is HANDLE,but the details of it is unknown.
However,I suppose,the code should be like this(I'm not good at coding of
Win32)
/******************************************************************************
* RegisterEventSourceW [ADVAPI32.@]
*
* See RegisterEventSourceA.
*/
HANDLE WINAPI RegisterEventSourceW( LPCWSTR lpUNCServerName, LPCWSTR
lpSourceName )
{
int arg_length,path_length;
LPDWORD existance;
LPWSTR reg_fullpath;
LPWSTR filename;
LPDWORD lptype;
LPWSTR lpdata,gldata;
HKEY hkeyp;
HANDLE eventhandle;
int number_of_entry,length_of_dat;

FIXME("(%s,%s): stub\n", debugstr_w(lpUNCServerName),
debugstr_w(lpSourceName));

if(lpUNCServerName!=NULL)
{
FIXME("lpUNCServerName:%s\nExecution in another server is not
suppported.", debugstr_w(lpUNCServerName));
}
else
{
existance = NULL;
number_of_entry = 0;
length_of_dat = 0;
filename = (LPWSTR)"Application";//FIXME:this should be all of sub keies.
reg_fullpath =
lstrcatW((LPWSTR)"System\\CurrentControlSet\\Sevices\\Eventlog\\Application\\",lpSourceName);
arg_length = lstrlenW(lpSourceName);
RegCreateKeyExW(HKEY_LOCAL_MACHINE,reg_fullpath,0,
NULL,REG_OPTION_NON_VOLATILE,KEY_READ,NULL,&hkeyp,existance);//Create or
open key.
RegQueryInfoKeyW(hkeyp,NULL,0,NULL,NULL,NULL,NULL,
(LPDWORD)number_of_entry,NULL,(LPDWORD)length_of_dat,NULL,NULL);
if(length_of_dat<2 || number_of_entry<2)//Key entry is void.
return NULL;
*lptype=(REG_SZ);
RegQueryValueExW(hkeyp,(LPWSTR)"EventMessageFile",NULL,lptype,(LPBYTE)lpdata,(LPDWORD)path_length);
RegCloseKey(hkeyp);
eventhandle = GlobalAlloc(GHND,(arg_length+path_length)*sizeof(LPWSTR));
gldata=(LPWSTR)GlobalLock(eventhandle);
//After that,store data follows:filename,file path,source name;I do not
know how to.
if(eventhandle==INVALID_HANDLE_VALUE)
{
ERR_(eventlog)("%s\n", debugstr_w(lpUNCServerName));
return NULL;
}
}
return eventhandle;
}



More information about the wine-devel mailing list