我打開一個DLL從system32(shell32.dll) ,我想要收到它的版本。 我該怎麼做?我開始寫它,但只是不知道如何繼續:如何獲取DLL的版本?
我也看到,有像這樣的函數:GetFileVersionSize,有沒有一種方法來使用它們?
這是代碼,如果有人能幫助我繼續,並提供線索,我會很approiciate它
的感謝!
#define PATH "C:\\Users\\rachel\\Desktop\\shell32.dll"
PVERSION dll_getVersion(PCHAR pDllPath)
{
PVERSION version = NULL;
HINSTANCE dllLoad = NULL;
HRSRC resourceHandle = NULL;
HGLOBAL loadResourceHandle = NULL;
LPVOID lockResourceHande = NULL;
DWORD sizeOfResource = 0;
//LPCTSTR lptstrFilename = NULL;
//DWORD dfHandle = 0;
//DWORD dwLen = 0;
//LPVOID lpData = NULL;
//BOOL test = FALSE;
//DWORD fileVersionSize = 0;
//unsigned long u = 0;
//fileVersionSize = GetFileVersionInfoSize(PATH , &u);
//test = GetFileVersionInfo(PATH, dfHandle , dwLen ,lpData);
if (NULL == pDllPath)
{
printf("error #1 : dllPath is invalid \n");
return version;
}
version = (PVERSION)calloc(1,sizeof(VERSION));
if (NULL == version)
{
printf("the allocation failed \n");
return version;
}
//opening the dll using the path */
dllLoad = LoadLibrary(pDllPath);
if (NULL == dllLoad)
{
printf("failed to load the dll ! \n");
printf("the last error is : %d\n" , GetLastError());
free(version);
version = NULL;
return version;
}
resourceHandle = FindResource(dllLoad ,MAKEINTRESOURCE(16) , RT_VERSION);
if (NULL == resourceHandle)
{
printf("problem with find resource!!!! \n");
return NULL;
}
loadResourceHandle = LoadResource(dllLoad , resourceHandle);
if (NULL == loadResourceHandle)
{
printf("problem with load resource function! \n");
return NULL;
}
lockResourceHande = LockResource(loadResourceHandle);
if (NULL == lockResourceHande)
{
printf("error in lock resource function \n");
return NULL;
}
sizeOfResource = SizeofResource(dllLoad, resourceHandle);
出於好奇,爲什麼你需要的dll,你開的版本號? – johnathon