Help with LNK2019 error and DiInstallDriver function - Programmer

This is a discussion on Help with LNK2019 error and DiInstallDriver function - Programmer ; Hello, I was hoping someone could help me with a compile issue I'm having in Visual Studio 2005 using the v6.0 Microsoft SDK. I apologize in advance if I'm posting to any groups that don't relate to this topic. I'm ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: Help with LNK2019 error and DiInstallDriver function

  1. Help with LNK2019 error and DiInstallDriver function

    Hello, I was hoping someone could help me with a compile issue I'm
    having in Visual Studio 2005 using the v6.0 Microsoft SDK. I
    apologize in advance if I'm posting to any groups that don't relate to
    this topic. I'm just trying to hit the groups that seem relevant.

    I have an application that is installing Drivers to the OS. I was
    using the UpdateDriverForPlugAndPlayDevices() function to handle
    this. It works fine, but on VISTA I get prompted by Windows Security
    if the Driver isn't pre-installed first. To avoid this I want to use
    the DiInstallDriver() function which will Pre-Install the driver first
    and then install it to any device that uses it.

    The problem I'm having is that everytime I try to compile now that
    I've added a reference in my code to DiInstallDriver(), I get the
    following error:

    Error 13 error LNK2019: unresolved external symbol _DiInstallDriverW
    referenced in function "private: void __thiscall
    ScanHardware::UpdateDriver(class ScanResult *)" (?
    UpdateDriver@ScanHardware@@AAEXPAVScanResult@@@Z) ScanHardware.obj
    Error 14 fatal error LNK1120: 1 unresolved externals C:\Projects
    \UIUHWScan++\Debug\UIUHWScan++.exe 1

    I'm a relative novice in the area of C++, so ANY help would be
    greatly appreciated.


  2. Re: Help with LNK2019 error and DiInstallDriver function

    Rymfax wrote:
    > Hello, I was hoping someone could help me with a compile issue I'm
    > having in Visual Studio 2005 using the v6.0 Microsoft SDK. I
    > apologize in advance if I'm posting to any groups that don't relate to
    > this topic. I'm just trying to hit the groups that seem relevant.
    >
    > I have an application that is installing Drivers to the OS. I was
    > using the UpdateDriverForPlugAndPlayDevices() function to handle
    > this. It works fine, but on VISTA I get prompted by Windows Security
    > if the Driver isn't pre-installed first. To avoid this I want to use
    > the DiInstallDriver() function which will Pre-Install the driver first
    > and then install it to any device that uses it.
    >
    > The problem I'm having is that everytime I try to compile now that
    > I've added a reference in my code to DiInstallDriver(), I get the
    > following error:
    >
    > Error 13 error LNK2019: unresolved external symbol _DiInstallDriverW
    > referenced in function "private: void __thiscall
    > ScanHardware::UpdateDriver(class ScanResult *)" (?
    > UpdateDriver@ScanHardware@@AAEXPAVScanResult@@@Z) ScanHardware.obj
    > Error 14 fatal error LNK1120: 1 unresolved externals C:\Projects
    > \UIUHWScan++\Debug\UIUHWScan++.exe 1
    >
    > I'm a relative novice in the area of C++, so ANY help would be
    > greatly appreciated.
    >


    http://msdn2.microsoft.com/en-us/library/aa906312.aspx

    Notice in this spec page for the function that is specifies "link to
    Newdev.lib". The function is inside that library. So you must add
    Newdev.lib to your program's linker settings.

    --
    Scott McPhillips [VC++ MVP]


  3. Re: Help with LNK2019 error and DiInstallDriver function

    On Apr 11, 11:43 am, "Scott McPhillips [MVP]" scottmcp> wrote:
    > Rymfax wrote:
    > > Hello, I was hoping someone could help me with a compile issue I'm
    > > having in Visual Studio 2005 using the v6.0 Microsoft SDK. I
    > > apologize in advance if I'm posting to any groups that don't relate to
    > > this topic. I'm just trying to hit the groups that seem relevant.

    >
    > > I have an application that is installing Drivers to the OS. I was
    > > using the UpdateDriverForPlugAndPlayDevices() function to handle
    > > this. It works fine, but on VISTA I get prompted by Windows Security
    > > if the Driver isn't pre-installed first. To avoid this I want to use
    > > the DiInstallDriver() function which will Pre-Install the driver first
    > > and then install it to any device that uses it.

    >
    > > The problem I'm having is that everytime I try to compile now that
    > > I've added a reference in my code to DiInstallDriver(), I get the
    > > following error:

    >
    > > Error 13 error LNK2019: unresolved external symbol _DiInstallDriverW
    > > referenced in function "private: void __thiscall
    > > ScanHardware::UpdateDriver(class ScanResult *)" (?
    > > UpdateDriver@ScanHardware@@AAEXPAVScanResult@@@Z) ScanHardware.obj
    > > Error 14 fatal error LNK1120: 1 unresolved externals C:\Projects
    > > \UIUHWScan++\Debug\UIUHWScan++.exe 1

    >
    > > I'm a relative novice in the area of C++, so ANY help would be
    > > greatly appreciated.

    >
    > http://msdn2.microsoft.com/en-us/library/aa906312.aspx
    >
    > Notice in this spec page for the function that is specifies "link to
    > Newdev.lib". The function is inside that library. So you must add
    > Newdev.lib to your program's linker settings.
    >
    > --
    > Scott McPhillips [VC++ MVP]- Hide quoted text -
    >
    > - Show quoted text -


    Thanks for replying Scott. That is what has me so confused. I do
    have newdev.lib in my linker settings. In the Project Properties
    under Linker->Input->Additional Dependencies, I have: Setupapi.lib
    newdev.lib

    I assume this is correct because UpdateDriverForPlugAndPlayDevices()
    works just fine and it is also in newdev.h (and thus newdev.lib I
    assume). And yet I still get the errors.

    Is there some other place I need to add linker settings? What would
    cause one function in the lib to link properly but not another?


  4. Re: Help with LNK2019 error and DiInstallDriver function

    Rymfax wrote:
    > Thanks for replying Scott. That is what has me so confused. I do
    > have newdev.lib in my linker settings. In the Project Properties
    > under Linker->Input->Additional Dependencies, I have: Setupapi.lib
    > newdev.lib
    >
    > I assume this is correct because UpdateDriverForPlugAndPlayDevices()
    > works just fine and it is also in newdev.h (and thus newdev.lib I
    > assume). And yet I still get the errors.
    >
    > Is there some other place I need to add linker settings? What would
    > cause one function in the lib to link properly but not another?
    >


    UpdateDriverForPlugAndPlayDevices has been available since Windows 2000.
    DiInstallDriver appears to be new with Vista? To make such new
    functions available in your build you need to set WINVER and
    _WIN32_WINNT to approriate values before including windows.h. You might
    review newdev.h for any similar versioning requirements, indicated by
    #ifdef/#endif around the function definition.

    When you #define high values for WINVER/_WIN32_WINNT it makes it
    impossible for your program to run on older versions of Windows.

    Details here: http://msdn2.microsoft.com/en-us/library/aa383745.aspx

    Another possibility: In your original post you said "using the v6.0
    Microsoft SDK". I'm not sure what version that means. If you have an
    old SDK then you have an old newdev.lib, and the function might not be
    present in the older library.

    --
    Scott McPhillips [VC++ MVP]


  5. Re: Help with LNK2019 error and DiInstallDriver function


    "Rymfax" wrote in message
    news:1176307715.518462.281140@n76g2000hsh.googlegr oups.com...
    > Hello, I was hoping someone could help me with a compile issue I'm
    > having in Visual Studio 2005 using the v6.0 Microsoft SDK. I
    > apologize in advance if I'm posting to any groups that don't relate to
    > this topic. I'm just trying to hit the groups that seem relevant.
    >
    > I have an application that is installing Drivers to the OS. I was
    > using the UpdateDriverForPlugAndPlayDevices() function to handle
    > this. It works fine, but on VISTA I get prompted by Windows Security
    > if the Driver isn't pre-installed first. To avoid this I want to use
    > the DiInstallDriver() function which will Pre-Install the driver first
    > and then install it to any device that uses it.
    >
    > The problem I'm having is that everytime I try to compile now that
    > I've added a reference in my code to DiInstallDriver(), I get the
    > following error:


    From the DiInstallDriver documentation:

    "Declared in newdev.h. Include newdev.h. Link to newdev.lib. "


    However, since this is a Vista-only function, I would suggest that you use
    LoadLibrary and GetProcAddress to call it if available, that way your app
    won't totally refuse to run on XP and earlier.


    >
    > Error 13 error LNK2019: unresolved external symbol _DiInstallDriverW
    > referenced in function "private: void __thiscall
    > ScanHardware::UpdateDriver(class ScanResult *)" (?
    > UpdateDriver@ScanHardware@@AAEXPAVScanResult@@@Z) ScanHardware.obj
    > Error 14 fatal error LNK1120: 1 unresolved externals C:\Projects
    > \UIUHWScan++\Debug\UIUHWScan++.exe 1
    >
    > I'm a relative novice in the area of C++, so ANY help would be
    > greatly appreciated.
    >




+ Reply to Thread