Hie,
I'm trying to get a code in a DLL runned each time a program is launched.
1) I have put this value in the registery key :
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Windows="D:\myDLL.dll"
2)
BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ ,
DWORD reason /* Reason this function is being called. */ ,
LPVOID reserved /* Not used. */ )
{
FILE *log = fopen("D:\\log.txt", "a");
fprintf(log, "DllMain called\n");
switch (reason)
{
case DLL_PROCESS_ATTACH:
fprintf(log,"DLL_PROCESS_ATTACH\n");
break;
case DLL_PROCESS_DETACH:
fprintf(log,"DLL_PROCESS_DETACH\n");
break;
case DLL_THREAD_ATTACH:
fprintf(log,"DLL_THREAD_ATTACH\n");
break;
case DLL_THREAD_DETACH:
fprintf(log,"DLL_THREAD_DETACH\n");
break;
}
fclose(log);
/* Returns TRUE on success, FALSE on failure */
return TRUE;
}
I compile MyDLL.DLL, put it on my D:\ drive. Afterwards, I run several .exe
The LOG.TXT file I expected to be created is just missing !!
Please can someone help me !