How to test a windows dll to determine if it is 32bit or 64bit?
Answer / Ankit Agrawal
To check whether a Windows DLL is 32-bit or 64-bit, you can use the `IMAGE_FILE_MACHINE` structure defined in the WinNT.h header file. Here's an example code snippet using Visual C++:
```cpp
#include <windows.h>
#include <stdio.h>
BOOL Is32BitDll(const char *dllPath) {
IMAGE_FILE_HEADER imageFileHeader;
HANDLE file = CreateFileA(dllPath, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (file == INVALID_HANDLE_VALUE) {
return false;
}
DWORD fileSize = GetFileSize(file, NULL);
ReadFile(file, &imageFileHeader, sizeof(IMAGE_FILE_HEADER), NULL, NULL);
CloseHandle(file);
return (imageFileHeader.Machine == IMAGE_FILE_MACHINE_I386); // returns true for 32-bit DLL
}
```
| Is This Answer Correct ? | 0 Yes | 0 No |
What is an application error?
Can a pentium 4 run windows 10?
How do I find windows server version?
What is the best email program for windows 7?
What is a code migration?
How do you solve windows cannot install required files?
What is offline defragmentation in AD and how do we do it?
Does windows 10 defender scan automatically?
How do I find missing dll files in windows 7?
Who created windows?
How do I run a script in windows?
What is my windows version?