再问:#define LoadLibrary LoadLibraryW 的使用
windows 里面的 (vs2010)
HMODULE
WINAPI
LoadLibraryW(
__in LPCWSTR lpLibFileName
);
#ifdef UNICODE
#define LoadLibrary LoadLibraryW
#else
#define LoadLibrary LoadLibraryA
#endif // !UNICODE
然后别人的一个程序里面这样写:
void Plugin::loadPlugin(string pluginName)
{
int length = pluginName.length();
WCHAR *pluginFile = new WCHAR[length+1];
MultiByteToWideChar(0, 0, pluginName.c_str(), -1, pluginFile, length+1);
// load plugin into memory
pluginLibrary = LoadLibrary(pluginFile);
现在我知道pluginName 的值是: HiballPlugin
然后工程里面有个文件夹plugins,里面有HiballPlugin.dll 但是貌似pluginFile的值并没有dll。 还有,也没有指定plugins的相对路径,程序如何获得HiballPlugin.dll?
非常感谢。水平不行, 望多指教。
[解决办法]
string pluginName你自己看着,通过这参数传进来,MultiByteToWideChar(0, 0, pluginName.c_str(), -1, pluginFile, length+1); 通过这个API转换成了宽字符,LoadLibrary(pluginFile); 加载该DLL,等到该句柄!
[解决办法]
断点跟踪!!
[解决办法]
你的工程目录下去找一下这个库,它就在下面,不然你程序跑步起来。
[解决办法]
1. rule for finding dll, see what msdn says, especially the mark section.
2. since path has been in wide chars, use the real function LoadLibaryW instead of the macro LoadLibary.
[解决办法]
那个DLL是可以不用写的,默认是DLL文件
[解决办法]
1,首先那个.dll是不用写上去,默认扩展名是.DLL
2,你的工程根目录下必须有这个DLL,不然你的程序跑不动
你去你的Debug/Release版本下找找
[解决办法]
再找不到,那就右击你的工程->C/C++->Additional Include Directories下看你的引入的头文件在哪个位置