Just a complement, if someone cannot run difxapi functions, you need by someway link your project to difxapi.h
and difxapi.lib
that came with WDK.
Fast way, just copy difxapi.h
and difxapi.lib
to your folder project and add to your project. Beware to chose this files that are compatilhe to x86 in wdk folder.
A simple code example, just for test, using C that run on win 7 32bit:
#include <windows.h>
#include <stdio.h>
#include "difxapi.h"
int main(void)
{
DWORD dwRet = 0;
PCTSTR DriverPackageInfPath = TEXT("D:\\MYDRIVER.INF");
DWORD Flags = 0;
INSTALLERINFO InstallerInfo;
BOOL bNeedReboot;
char chName[] = "Thing Name";
char chGUID[] = "{4D36E979-E325-11CE-BFC1-08002BE10318}"; //printer GUID
InstallerInfo.pDisplayName = &chName;
InstallerInfo.pProductName = &chName;
InstallerInfo.pMfgName = &chName;
InstallerInfo.pApplicationId = &chGUID;
dwRet = DriverPackageInstall( DriverPackageInfPath, Flags, &InstallerInfo , &bNeedReboot );
switch(dwRet)
{
case ERROR_SUCCESS:
printf("\n\n ERROR_SUCCESS - Ret: %d, %xh", dwRet, dwRet);
break;
case CERT_E_EXPIRED:
printf("\n\n CERT_E_EXPIRED - Ret: %d, %xh", dwRet, dwRet);
break;
case CERT_E_UNTRUSTEDROOT:
printf("\n\n CERT_E_UNTRUSTEDROOT - Ret: %d, %xh", dwRet, dwRet);
break;
case CERT_E_WRONG_USAGE:
printf("\n\n CERT_E_WRONG_USAGE - Ret: %d, %xh", dwRet, dwRet);
break;
case CRYPT_E_FILE_ERROR:
printf("\n\n CRYPT_E_FILE_ERROR - Ret: %d, %xh", dwRet, dwRet);
break;
case ERROR_ACCESS_DENIED:
printf("\n\n ERROR_ACCESS_DENIED - Ret: %d, %xh", dwRet, dwRet);
break;
case ERROR_BAD_ENVIRONMENT:
printf("\n\n ERROR_BAD_ENVIRONMENT - Ret: %d, %xh", dwRet, dwRet);
break;
case ERROR_CANT_ACCESS_FILE:
printf("\n\n ERROR_CANT_ACCESS_FILE - Ret: %d, %xh", dwRet, dwRet);
break;
case ERROR_FILE_NOT_FOUND:
printf("\n\n ERROR_FILE_NOT_FOUND - Ret: %d, %xh", dwRet, dwRet);
break;
case ERROR_FILENAME_EXCED_RANGE:
printf("\n\n ERROR_FILENAME_EXCED_RANGE - Ret: %d, %xh", dwRet, dwRet);
break;
/*case ERROR_IN_WOW64:
printf("\n\n ERROR_IN_WOW64 - Ret: %d, %xh", dwRet, dwRet);
break;*/
case ERROR_INSTALL_FAILURE:
printf("\n\n ERROR_INSTALL_FAILURE - Ret: %d, %xh", dwRet, dwRet);
break;
case ERROR_INVALID_CATALOG_DATA:
printf("\n\n ERROR_INVALID_CATALOG_DATA - Ret: %d, %xh", dwRet, dwRet);
break;
case ERROR_INVALID_NAME:
printf("\n\n ERROR_INVALID_NAME - Ret: %d, %xh", dwRet, dwRet);
break;
case ERROR_INVALID_PARAMETER:
printf("\n\n ERROR_INVALID_PARAMETER - Ret: %d, %xh", dwRet, dwRet);
break;
case ERROR_NO_DEVICE_ID:
printf("\n\n ERROR_NO_DEVICE_ID - Ret: %d, %xh", dwRet, dwRet);
break;
case ERROR_NO_MORE_ITEMS:
printf("\n\n ERROR_NO_MORE_ITEMS - Ret: %d, %xh", dwRet, dwRet);
break;
case ERROR_NO_SUCH_DEVINST:
printf("\n\n ERROR_NO_SUCH_DEVINST - Ret: %d, %xh", dwRet, dwRet);
break;
case ERROR_OUTOFMEMORY:
printf("\n\n ERROR_OUTOFMEMORY - Ret: %d, %xh", dwRet, dwRet);
break;
case ERROR_SHARING_VIOLATION:
printf("\n\n ERROR_SHARING_VIOLATION - Ret: %d, %xh", dwRet, dwRet);
break;
case ERROR_SIGNATURE_OSATTRIBUTE_MISMATCH:
printf("\n\n ERROR_SIGNATURE_OSATTRIBUTE_MISMATCH - Ret: %d, %xh", dwRet, dwRet);
break;
case ERROR_UNSUPPORTED_TYPE:
printf("\n\n ERROR_UNSUPPORTED_TYPE - Ret: %d, %xh", dwRet, dwRet);
break;
case TRUST_E_NOSIGNATURE:
printf("\n\n TRUST_E_NOSIGNATURE - Ret: %d, %xh", dwRet, dwRet);
break;
default:
printf("\n\n default - Ret: %d, %xh", dwRet, dwRet);
break;
}
printf("\n\n");
system("pause");
return 1;
}