我正在查看.dll文件,我了解它们的用法,我正在尝试了解如何使用它们.
我创建了一个.dll文件,其中包含一个返回名为funci()的整数的函数
使用此代码,我(想)我已将.dll文件导入项目(没有投诉):
#include <windows.h>
#include <iostream>
int main() {
HINSTANCE hGetProcIDDLL = LoadLibrary("C:\\Documents and Settings\\User\\Desktop \\fgfdg\\dgdg\\test.dll");
if (hGetProcIDDLL == NULL) {
std::cout << "cannot locate the .dll file" << std::endl;
} else {
std::cout << "it has been called" << std::endl;
return -1;
}
int a = funci();
return a;
}
# funci function
int funci() {
return 40;
}
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试编译我认为已导入.dll的.cpp文件时,我遇到以下错误:
C:\Documents and Settings\User\Desktop\fgfdg\onemore.cpp||In function 'int main()':|
C:\Documents and Settings\User\Desktop\fgfdg\onemore.cpp|16|error: 'funci' was not declared in this scope|
||=== Build …Run Code Online (Sandbox Code Playgroud)