How to test a windows dll to determine if it is 32bit or 64bit?
Answer Posted / 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 |
Post New Answer View All Answers
When will the next windows os come out?
What is the current version of windows 10?
How does registry work wedding?
How much does it cost for a copy of windows 10?
What is the latest windows operating system?
How much does a copy of windows 10 cost?
What is the next windows after 10?
How much does a windows 10 license cost?
What is the next version of windows after 10?
What is the latest version of microsoft edge for windows 10?
What does it cost to upgrade to windows 10?
How do I add a google account to windows 10?