I am calling SetupCopyOEMInf
to copy a .inf file for a device driver (the MSFT docs say: 'SetupAPI continues to be used for installing device drivers').
The call is returning false, so I am then calling GetLastError
as the docs say (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
). The value returned here is E000024B
or 3758096971
in decimal. However, when I call FormatMessage
as prescribed with the return value from GetLastError
, lpBuffer
is NULL.
Also trying to figure out why SetupCopyOEMInf
would be failing (it seems to work on some .inf files but not others). This is Windows 8.1
Puzzling...Any ideas out there?
Thanks!
Code:
BOOL result = SetupCopyOEMInf(_T("C:\\Users\\edward\\Desktop\\_Test\\cncport.inf"), NULL, SPOST_PATH, 0, NULL, 0, NULL, NULL);
//result is FALSE
LPVOID lpBuffer;
DWORD dw = GetLastError();
DWORD dwMsg = FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&lpBuffer,
2048, NULL);
FORMAT_MESSAGE_FROM_SYSTEM
does not support all error codes. The one you found is ERROR_FILE_HASH_NOT_IN_CATALOG
which is not covered by FORMAT_MESSAGE_FROM_SYSTEM
. The setupapi.h
errors do not appear to have any predefined text for them in a system message resource. You will have to write the error strings yourself.