CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2011
    Posts
    1

    Question Installing a driver programmatically using INF file C++

    Hi, could someone here please let me know how to install 3rd party device drivers
    programmatically if all the required files i.e. inf file, .sys etc are provided. The
    minimum operating system this solution SHOULD work on is Windows2000.

    I tried copying the .inf file into the Win Folder\INF folder and the sys file
    into the Win folder\system32\drivers but each time plug in the device, windows
    pops up Found New Hardware user interface which is what i am trying to avoid.

    Below is something i tried but the function returns error 87 (The parameter is incorrect).

    Thanks.


    HINF HInf;
    UINT ErrorLine;
    BOOL bRes = FALSE;
    PBOOL FileWasInUse = FALSE;

    LPCSTR szSourceFileName = _T("C:\\Drivers_HypercomP1320\\hypvcpusb.inf");
    LPCSTR szInfFileName = _T("hypvcpusb.inf");
    PVOID Context = NULL;

    HInf = SetupOpenInfFile ( szSourceFileName, NULL, INF_STYLE_WIN4, &ErrorLine);

    LPCSTR SourceFile = ("hypvcp.sys");
    LPCSTR SourcePathRoot = _T("C:\\Drivers_HypercomP1320");
    LPCSTR DestinationName = _T("C:\\WINDOWS\\system32\\drivers\\hypvcp.sys");

    bRes = SetupInstallFileEx ( HInf, NULL, SourceFile, SourcePathRoot, DestinationName, SP_COPY_FORCE_IN_USE,
    (PSP_FILE_CALLBACK)CopyMsgHandler, Context, FileWasInUse);

    DWORD dwVal = GetLastError();

    SetupCloseInfFile(HInf);


    // Callback function
    UINT CopyMsgHandler (UINT Context, UINT Notification,UINT_PTR Param1, UINT_PTR Param2)
    {
    UINT rtnValue = NO_ERROR;
    return rtnValue;
    }

  2. #2
    Join Date
    Jun 2011
    Posts
    3

    Re: Installing a driver programmatically using INF file C++

    HI,
    You need not copy the sys file into the drivers folder. That is specified in INF file where to copy. system will copy the sys file to drivers folder. once check the INF file is copied or not. Check whether cat file is present or not??

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured