C++ 使用其他DLL&;依赖性

C++ 使用其他DLL&;依赖性,c++,dll,dependencies,C++,Dll,Dependencies,我有一个使用DLL加密文件的程序。我想写一个程序,利用DLL,这样我也可以用同样的算法加密文件。然而,我对使用DLL还不熟悉,所以遇到了一些问题 我做了一些研究,得到了一些几乎可以工作的东西,但我认为我尝试使用的DLL有其他依赖项,我也不知道如何正确加载它们 这是我现在的代码: #include "stdafx.h" #include <conio.h> // Header file containing getch() prototype #include <iost

我有一个使用DLL加密文件的程序。我想写一个程序,利用DLL,这样我也可以用同样的算法加密文件。然而,我对使用DLL还不熟悉,所以遇到了一些问题

我做了一些研究,得到了一些几乎可以工作的东西,但我认为我尝试使用的DLL有其他依赖项,我也不知道如何正确加载它们

这是我现在的代码:

#include "stdafx.h"
#include <conio.h>     // Header file containing getch() prototype
#include <iostream>
#include <string>
#include <windows.h> 

using namespace std;

typedef string(*CRYPT)(string);

int _tmain(int argc, _TCHAR* argv[])
{
    CRYPT  encrypt;
    HMODULE hMod;        // handle to loaded library module
    BOOL    bRes;        // BOOL to check if DLL was successfully unloaded 

    // returns a handle to the DLL, otherwise NULL
    hMod = LoadLibraryA("ChangedName.dll");
    if (hMod == NULL)
    {
        cout << "NULL" << endl;
        system("PAUSE");
        return 1;
    }

    // returns the address of the DLL functions, otherwise NULL
    encrypt = (CRYPT)GetProcAddress(hMod, "Encrypt");

    // function call
    string enc = (encrypt)("this is a string");

    cout << "Encrypted: " << enc << endl;
    cout << "Press a key to exit" << endl;
    _getch();

    bRes = FreeLibrary(hMod);
    return 0;
}

错误发生在
string enc=(encrypt)(“这是一个字符串”)

崩溃发生在哪一行?
string enc=(加密)(“这是一个字符串”)
我猜
GetProcAddress
正在返回
NULL
。你检查过了吗?我相信它返回空值,但我不知道如何修复它(使用DependencyWalker,我看不到列出的任何函数。我得到的只是一个其他系统DLL的列表和一个红色注释,说明
警告:至少一个延迟加载依赖模块未找到。警告:由于延迟加载依赖模块中缺少导出函数,至少有一个模块具有未解析的导入。
'Project1.exe' (Win32): Loaded 'C:\Users\REMOVED\Documents\Visual Studio 2013\Projects\Project1\Debug\Project1.exe'. Symbols loaded.
'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file.
'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file.
'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file.
'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp120d.dll'. Cannot find or open the PDB file.
'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr120d.dll'. Cannot find or open the PDB file.
'Project1.exe' (Win32): Loaded 'C:\Users\REMOVED\Documents\Visual Studio 2013\Projects\Project1\Debug\L2TowerUtils.dll'. Module was built without symbols.
'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\psapi.dll'. Cannot find or open the PDB file.
'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Cannot find or open the PDB file.
'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ole32.dll'. Cannot find or open the PDB file.
'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\oleaut32.dll'. Cannot find or open the PDB file.
'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr110.dll'. Cannot find or open the PDB file.
'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp110.dll'. Cannot find or open the PDB file.
'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\mscoree.dll'. Cannot find or open the PDB file.
'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Cannot find or open the PDB file.
'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Cannot find or open the PDB file.
'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Cannot find or open the PDB file.
'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\combase.dll'. Cannot find or open the PDB file.
'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32.dll'. Cannot find or open the PDB file.
'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\user32.dll'. Cannot find or open the PDB file.
'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Cannot find or open the PDB file.
'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Cannot find or open the PDB file.
'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\bcryptprimitives.dll'. Cannot find or open the PDB file.
'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Cannot find or open the PDB file.
'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Cannot find or open the PDB file.
'Project1.exe' (Win32): Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscoreei.dll'. Cannot find or open the PDB file.
'Project1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shlwapi.dll'. Cannot find or open the PDB file.
First-chance exception at 0x00000000 in Project1.exe: 0xC0000005: Access violation executing location 0x00000000.
Unhandled exception at 0x7791BDA1 in Project1.exe: 0xC0000005: Access violation executing location 0x00000000.