简体   繁体   中英

C++ DLL Not running on Windows XP when built with Windows 7

I'm a total newb to c++ but I needed to add some methods to an existing c++ dll. The dll was originally built with Visual Studio 2008 and it worked on Windows 7 and Windows XP. After I added my methods and built the dll again it still worked on Windows 7 but not on XP. I call the dll from Java and get the following exception:

CLI异常 After searching around on SO a bit I found Dependency Walker which shows me this:

依赖行者

The command line options for compiling are

/GS /analyze- /W3 /Gy /Zc:wchar_t /Zi /Gm- /O2 /Ob1 /Fd".\\Release/" /Zc:inline /fp:precise /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "NTPROCESSDLL_EXPORTS" /D "_VC80_UPGRADE=0x0600" /D "_USING_V110_SDK71_" /D "_WINDLL" /D "_MBCS" /errorReport:prompt /GF /WX- /Zc:forScope /Gd /Oy- /MT /Fa".\\Release/" /EHsc /nologo /Fo".\\Release/" /Fp".\\Release/NTProcessDLL.pch"

And the linker command is

/OUT:".\\Release\\NTProcessDLL.dll" /MANIFEST /PDB:".\\Release/NTProcessDLL.pdb" /DYNAMICBASE:NO "pdh.lib" /DEF:".\\NTProcessDLL.def" /IMPLIB:".\\Release/NTProcessDLL.lib" /DEBUG /DLL /MACHINE:X86 /SAFESEH /INCREMENTAL:NO /PGD:".\\Release\\NTProcessDLL.pgd" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:".\\Release\\NTProcessDLL.dll.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /TLBID:1

And the methods I added are these:

void _minimizeProcess(long nPid)
{
    EnumWindows(EnumWindowsProcMinimize, nPid);
}


BOOL CALLBACK EnumWindowsProcMinimize(HWND hwnd, LPARAM lParam)
{
    HWND g_HWND = NULL;
    DWORD lpdwProcessId;
    GetWindowThreadProcessId(hwnd, &lpdwProcessId);
    if (lpdwProcessId == lParam)
    {
        g_HWND = hwnd;
        ShowWindow(g_HWND, SW_MINIMIZE);
        CloseHandle(g_HWND);
        Sleep(1);
        return FALSE;
    }
    return TRUE;
}

Any help to get this running on XP would be highly appreciated. Many thanks in advance!

I also ran into similar problems in the past, those _xp toolsets never worked. Download and install Visual Studio 2010 ( LINK ). Then run your Visual Studio 2015 and go to compiler options, you should have there a new toolset - vs100. Compile your library with that and it should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM