Hello to all,
I was trying to install an .inf from this function call SetupInstallFilesFromInfSection, but getting error 13 from func. SetupCommitFileQueue.
#include <windows.h> // includes basic windows functionality
#include <regstr.h>
#include <setupapi.h> // includes the inf setup api
int main(int argc, char* argv)
{
HINF hinf;
BOOL bResult=FALSE, dwResult=FALSE;
HSPFILEQ FileQueue;
PVOID context;
hinf = SetupOpenInfFile ( argv[1], NULL, INF_STYLE_WIN4, NULL);
if (hinf == INVALID_HANDLE_VALUE)
{
printf(“func:: SetupOpenInfFile() \n argv[1]=%s\nhinf get INVALID_HANDLE_VALUE :: %d\n”,argv[1],GetLastError());
dwResult = GetLastError();
return FALSE;
}
FileQueue = SetupOpenFileQueue();
if(!FileQueue || (FileQueue == INVALID_HANDLE_VALUE))
{
printf(“func:: SetupOpenFileQueue() \n”);
dwResult = ERROR_NOT_ENOUGH_MEMORY;
SetupCloseInfFile(hinf);
return FALSE;
}
context = SetupInitDefaultQueueCallbackEx(NULL, NULL, 0, 0, NULL);
// context = SetupInitDefaultQueueCallbackEx(NULL, (HWND)INVALID_HANDLE_VALUE, 0, 0, NULL);
if(!(context))
{
printf(“func:: context=SetupInintDefaultQueueCallbackEx() \n”);
dwResult = ERROR_NOT_ENOUGH_MEMORY;
SetupCloseFileQueue(FileQueue);
SetupCloseInfFile(hinf);
return FALSE;
}
bResult = SetupInstallFilesFromInfSection(hinf, NULL, FileQueue, “DefaultInstall”, “.”, SP_COPY_NEWER);
if(bResult) {
bResult = SetupCommitFileQueue(NULL, FileQueue, (PSP_FILE_CALLBACK) SetupInitDefaultQueueCallbackEx, &context);
if(!bResult)
{
printf(“func:: SetupCommitFileQueue() \nerror=%d\n”,GetLastError());
SetupCloseFileQueue(FileQueue);
SetupCloseInfFile(hinf);
return bResult;
}
dwResult = bResult ? NO_ERROR : GetLastError();
} else {
printf(“func:: context=SetupInstallFilesFromInfSection() \nerror=%d\n”,GetLastError());
dwResult = GetLastError();
}
SetupTermDefaultQueueCallback(context);
SetupCloseFileQueue(FileQueue);
SetupCloseInfFile(hinf);
return 0;
}
Basically I am getting error from func SetupCommitFileQueue.
same Inf file is getting successfully installed via advpack.lib using rundll32.exe</setupapi.h></regstr.h></windows.h>