我使用ATL开发了一个SHELL扩展程序,开发环境VS9,32位正常,64位 regsvr32 时出现提示 “可能与您正在运行的 Windows 版本不兼容。检查该模块是否与 regsvr32.exe 的 x86(32 位)或 x64(64 位)版本兼容”。
然后我写了个独立的小程序, LoadLibrary 此模块,发现无法加载。
求教64位玩的比较熟的选手来帮忙。
注:我的工程设置为静态链接ATL和CRT
使用 dumpbin 得到导入表信息如下:
(CSDN提示贴子太长,导入表信息发在下一楼)

解决方案 »

  1.   


    File Type: DLL
      Section contains the following imports:    KERNEL32.dll                         139 FindResourceExW
                             491 WriteFile
                              80 CreateFileW
                              72 CreateDirectoryW
                             1CF GetFileAttributesW
                             437 TlsFree
                             436 TlsAlloc
                             3DF SetFileAttributesW
                             3E8 SetFileTime
                             1CC GetFileAttributesExW
                             362 ReadFile
                             1D6 GetFileSizeEx
                             3D2 SetEndOfFile
                             3E4 SetFilePointer
                             3E5 SetFilePointerEx
                             3F0 SetLastError
                              CB DeviceIoControl
                             334 OutputDebugStringA
                             281 GetWindowsDirectoryW
                             2EE LoadLibraryW
                             3D8 SetEvent
                             322 OpenEventW
                             384 ResetEvent
                             468 WaitForSingleObject
                              76 CreateEventW
                             438 TlsGetValue
                             4BA lstrcpynA
                             4BB lstrcpynW
                             439 TlsSetValue
                             297 GlobalUnlock
                             425 Sleep
                             290 GlobalLock
                             142 FlushFileBuffers
                              79 CreateFileA
                             490 WriteConsoleW
                             19A GetConsoleOutputCP
                             301 LockResource
                             400 SetStdHandle
                             196 GetConsoleMode
                             184 GetConsoleCP
                             1E8 GetLocaleInfoA
                             240 GetStringTypeW
                             23D GetStringTypeA
                             2DD LCMapStringW
                             2DB LCMapStringA
                             2B5 InitializeCriticalSectionAndSpinCount
                             2EB LoadLibraryA
                             24F GetSystemTimeAsFileTime
                             1AB GetCurrentProcessId
                             34E QueryPerformanceCounter
                              BF DeleteCriticalSection
                             2B4 InitializeCriticalSection
                             25F GetThreadLocale
                             40D SetThreadLocale
                             2ED LoadLibraryExW
                             13A FindResourceW
                             2F0 LoadResource
                             424 SizeofResource
                             14D FreeLibrary
                             1F5 GetModuleFileNameW
                             4B5 lstrcmpiW
                             1F9 GetModuleHandleW
                              43 CloseHandle
                             220 GetProcAddress
                             1E6 GetLastError
                             2E9 LeaveCriticalSection
                              DA EnterCriticalSection
                             354 RaiseException
                             4BE lstrlenW
                             266 GetTickCount
                             47E WideCharToMultiByte
                             153 GetACP
                             314 MultiByteToWideChar
                              A3 CreateThread
                             1C2 GetEnvironmentStringsW
                             14C FreeEnvironmentStringsW
                             1C0 GetEnvironmentStrings
                             14B FreeEnvironmentStringsA
                             239 GetStartupInfoA
                             1D8 GetFileType
                             3EC SetHandleCount
                             2D5 IsValidCodePage
                             213 GetOEMCP
                             15C GetCPInfo
                             2A6 HeapSize
                             2A4 HeapReAlloc
                             13D FlsAlloc
                             13E FlsFree
                             13F FlsGetValue
                              B8 DecodePointer
                              D6 EncodePointer
                             1F4 GetModuleFileNameA
                             23B GetStdHandle
                             105 ExitProcess
                             2A0 HeapDestroy
                             29F HeapCreate
                             2A5 HeapSetInformation
                             170 GetCommandLineA
                             140 FlsSetValue
                             1C7 GetExitCodeThread
                             432 TerminateThread
                             486 WriteConsoleA
                             2A1 HeapFree
                             29D HeapAlloc
                             392 RtlPcToFileHeader
                             390 RtlLookupFunctionEntry
                             396 RtlUnwindEx
                             431 TerminateProcess
                             1AA GetCurrentProcess
                             442 UnhandledExceptionFilter
                             419 SetUnhandledExceptionFilter
                             2CB IsDebuggerPresent
                             397 RtlVirtualUnwind
                             389 RtlCaptureContext
                             1AE GetCurrentThreadId
                             223 GetProcessHeap    USER32.dll                         280 SetForegroundWindow
                             27D SetDlgItemTextW
                             123 GetDlgItemTextA
                             192 GetWindowTextLengthW
                             121 GetDlgItem
                             267 SendMessageW
                             157 GetParent
                             310 wsprintfW
                             11C GetDC
                              C0 DrawIconEx
                             250 ReleaseDC
                              9D DestroyIcon
                              64 CreateMenu
                             1AA InsertMenuW
                             289 SetMenuItemBitmaps
                              CF EnableMenuItem
                              2F CharNextW
                             1DB LoadIconW
                             2AF SetWindowPos
                             2C0 ShowWindow
                              A6 DialogBoxParamW
                              D3 EndDialog
                              D1 EnableWindow
                             2AC SetWindowLongPtrW
                             11B GetCursorPos
                             258 ScreenToClient
                              EF FillRect
                             10F GetClientRect
                             1AE InvalidateRect    GDI32.dll
                 18001D070 Import Address Table
                 180026010 Import Name Table
                         0 time date stamp
                         0 Index of first forwarder reference                         266 SetBkMode
                              28 CreateBitmap
                              2E CreateCompatibleDC
                             1F4 GetStockObject
                              CD DeleteDC
                              2A CreateBrushIndirect
                              D0 DeleteObject
                             28D SetTextColor
                             2A0 TextOutW
                              49 CreatePen
                             25E SelectObject
                             246 Rectangle    ADVAPI32.dll
                             262 RegQueryInfoKeyW
                             242 RegDeleteValueW
                             22A RegCloseKey
                             12A GetFileSecurityW
                             2A4 SetFileSecurityW
                             249 RegEnumKeyExW
                             23E RegDeleteKeyW
                             278 RegSetValueExW
                             25B RegOpenKeyExW
                             233 RegCreateKeyExW    SHELL32.dll
                 18001D4C8 Import Address Table
                 180026468 Import Name Table
                         0 time date stamp
                         0 Index of first forwarder reference                          20 DragQueryFileW    ole32.dll
                             14E ReleaseStgMedium
                              14 CoCreateInstance
                              6A CoTaskMemAlloc
                              6C CoTaskMemRealloc
                              6B CoTaskMemFree
                             177 StringFromGUID2    OLEAUT32.dll
                 18001D480 Import Address Table
                 180026420 Import Name Table
                         0 time date stamp
                         0 Index of first forwarder reference                             Ordinal     7
                                 Ordinal     6
                                 Ordinal     2
                                 Ordinal   161
                                 Ordinal   186
                                 Ordinal   163
                                 Ordinal   277
                                 Ordinal   162    SHLWAPI.dll
                 18001D4D8 Import Address Table
                 180026478 Import Name Table
                         0 time date stamp
                         0 Index of first forwarder reference                          34 PathAppendW
                              45 PathFileExistsW
                              FA SHSetValueW
                              C1 SHGetValueW
                              C0 SHGetValueA    COMCTL32.dll
                 18001D058 Import Address Table
                 180025FF8 Import Name Table
                         0 time date stamp
                         0 Index of first forwarder reference                           9 CreatePropertySheetPageW
                                 Ordinal    17  Summary        5000 .data
            3000 .pdata
            B000 .rdata
            1000 .reloc
            6000 .rsrc
           1C000 .text
      

  2.   

    SHELL扩展 64位系统, 你要重新编译一个64位的版本
      

  3.   

    在64位机上,我的DLL已经是64位的了。
      

  4.   

    用 \Windows\system32 下的Regsvr32.exe注册64bit DLL.
      

  5.   


    从运行对话框直接 regsvr32 运行的居然是32位的……还非得手工指定 C:\windows\system32\regsvr32.exe 
    拜了。
      

  6.   

    谢谢大牛回复,已解决,正如4楼说的……用 C:\windows\system32 下的 regsvr32 就行了。
    我之前直接用 regsvr32 ,不料居然优先使用 sysWow64 下的。
    这点我始料未及,因为我是通过 explorer 的运行对话框运行的,EXPLORER自然是64位,64位的EXPLORER找regsvr32 居然找去 sysWow64?
      

  7.   

    这个不应该依赖Explorer,而是自己用命令行调用,这样才能准确