HMODULE m_hNewDev = ::LoadLibrary("NEWDEV.dll");做了一个Storage控制程序,
运行这句就出现找不到指定的模块~!

解决方案 »

  1.   

    不行....NEWDEV.dll是C:\WINNT\system32下的.
    2000  pro系统
      

  2.   

    UINT GetSystemDirectory(
      LPTSTR lpBuffer,  // address of buffer for system directory
      UINT uSize        // size of directory buffer
    );
     
    Parameters
    lpBuffer 
    Pointer to the buffer to receive the null-terminated string containing the path. This path does not end with a backslash unless the system directory is the root directory. For example, if the system directory is named WINDOWS\SYSTEM on drive C, the path of the system directory retrieved by this function is GetSystemDirectory. 
    uSize 
    Specifies the maximum size of the buffer, in characters. This value should be set to at least MAX_PATH. GetSystemDirectory获得System32,然后使用绝对路径试试!如果还是不行看看是否存在那个DLL,呵呵
    再就是你自己程序的原因了!
      

  3.   

    int InstallDriver(char* vendorbuffer)
    {
    ExtractFile();
    DWORD Length;
    HDEVINFO DeviceInfoSet = 0;
    SP_DEVINFO_DATA DeviceInfoData;
    SP_INTERFACE_DEVICE_DATA InterfaceDeviceData;
    PSP_INTERFACE_DEVICE_DETAIL_DATA InterfaceDeviceDetailData;

    BYTE buffer[512] = {0};
    DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
    InterfaceDeviceData.cbSize = sizeof(SP_INTERFACE_DEVICE_DATA);

    DeviceInfoSet = SetupDiGetClassDevs((LPGUID)&SNXDisk_GUID,0,0,DIGCF_DEVICEINTERFACE|DIGCF_PRESENT);//|DIGCF_PRESENT);

    if (DeviceInfoSet == INVALID_HANDLE_VALUE)
            return 0;
    DWORD i =0;
    for (i=0;SetupDiEnumDeviceInterfaces(DeviceInfoSet,NULL,(LPGUID)&SNXDisk_GUID,i,&InterfaceDeviceData);i++)
    {
    SetupDiEnumDeviceInfo(DeviceInfoSet,i,&DeviceInfoData);
    DWORD DataT;
    ZeroMemory(buffer,512*sizeof(BYTE));
    SetupDiGetDeviceRegistryProperty(
    DeviceInfoSet,
    &DeviceInfoData,
    SPDRP_HARDWAREID,
    &DataT,
    (BYTE*) buffer,
    512,
    NULL); SetupDiGetDeviceInterfaceDetail(DeviceInfoSet,&InterfaceDeviceData,NULL,0,&Length,NULL);

    InterfaceDeviceDetailData = (PSP_INTERFACE_DEVICE_DETAIL_DATA)(new BYTE[Length]);
    if( NULL == InterfaceDeviceDetailData)
    {
    SetupDiDestroyDeviceInfoList(DeviceInfoSet);
    return 0;
    }
    InterfaceDeviceDetailData->cbSize = sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA);
    if(!SetupDiGetDeviceInterfaceDetail(DeviceInfoSet,&InterfaceDeviceData,InterfaceDeviceDetailData,Length,NULL,NULL))
    {
    SetupDiDestroyDeviceInfoList(DeviceInfoSet);
    delete InterfaceDeviceDetailData;
    return 0;
    }
    char tempBuffer[100] = {0};
    int n = strlen(vendorbuffer);
    memcpy(tempBuffer,InterfaceDeviceDetailData->DevicePath+4,n);
    delete InterfaceDeviceDetailData;
    if (_strcmpi((LPSTR)tempBuffer, (LPSTR) vendorbuffer) == 0)
    {
    char szWindowsDir[MAX_PATH] = {0};
    GetWindowsDirectory(szWindowsDir,MAX_PATH);
    strcat(szWindowsDir,"\\INF\\USBSNX2K.INF\0");
    BOOL bRebootRequired = FALSE;
    SetupDiDestroyDeviceInfoList(DeviceInfoSet);
    char szWindowsSys[MAX_PATH] = {0};
    GetSystemDirectory(szWindowsSys,MAX_PATH);
    HMODULE m_hNewDev = ::LoadLibrary("NEWDEV.dll");
    if (!m_hNewDev)
    return SNX_ERROR;
    UpdateDriver updateDriver;
    updateDriver = (UpdateDriver) GetProcAddress(m_hNewDev,"UpdateDriverForPlugAndPlayDevicesA");
    if (!updateDriver)
    {
    FreeLibrary(m_hNewDev);
    return SNX_ERROR;
    }
    bool brtn = updateDriver(0,
    (char*)buffer,
    szWindowsDir,
    INSTALLFLAG_FORCE,
    &bRebootRequired);
    FreeLibrary(m_hNewDev);
    if(bRebootRequired)
    return SNX_REBOOT;
    return SNX_OK;
    }
    }
    SetupDiDestroyDeviceInfoList(DeviceInfoSet);
    return SNX_ERROR;
    }全路径也不行,我的程序是查找第几个USB设备进行驱动升级~!
      

  4.   

    你想办法把NEWDEV.dll拷贝到当前程序的目录下
      

  5.   

    1.使用GetLastError();看看失败的原因是什么.Error Lookup+获得的错误代码
    2.找到NEWDEV.dll这个文件,然后用Depends看看其依存的DLL是否都存在.
      

  6.   

    GetLastError();
    错误代码,找不到指定的模块~!LoadLibray不是可以查找C:\WINNT\system32(系统目录下的文件啊)。。我想可能是程序的问题,但是不知道怎么解决~!?
    晕~!
      

  7.   

    先用OpenFile,看看是否也报告这个错误
    找到NEWDEV.dll这个文件,然后用Depends看看其依存的DLL是否都存在.
    有时候,以来的DLL不存在也会使得LoadLibray失败
      

  8.   

    这是MSDN上LoadLibrary载入DLL的顺序(默认情况)
    1.The directory from which the application loaded. 
    2.The current directory. 
    3.Windows 95/98: The Windows system directory. Use the GetSystemDirectory function to get the path of this directory. 
    Windows NT/ 2000: The 32-bit Windows system directory. Use the GetSystemDirectory function to get the path of this directory. The name of this directory is SYSTEM32. 4.Windows NT/ 2000: The 16-bit Windows system directory. There is no function that obtains the path of this directory, but it is searched. The name of this directory is SYSTEM. 
    5.The Windows directory. Use the GetWindowsDirectory function to get the path of this directory. 
    6.The directories that are listed in the PATH environment variable. 
    所以我估计应该和路径无关.
    还有检查你的NEWDEV.dll的版本和依存dll是否存在.
    我的NEWDEV.dll的版本是5.02195.6754
    我的win2k是Professional SP4.