以下是零基础学Visual C++中一节的主调函数的代码,其他的就不用写了LoadLibrary和FreeLibrary都放在里
#include <iostream>
#include <windows.h>
using namespace std;typedef void (*PFDlgShow)(int,int);
int main()
{
int score1,score2;
cout<<"本程序采用显式链接的方式测试开发MFC规则DLL\n";

while (true)
{
HINSTANCE hdll;
PFDlgShow dlgshow;
hdll=LoadLibrary("..\\RegularDll.dll");
if (hdll!=NULL)
{
dlgshow=(PFDlgShow)GetProcAddress(hdll,"ShowDlg");
}
cout<<"请输入文化成绩:\n";
cin>>score1;
cout<<"请输入艺术成绩:\n";
cin>>score2;
dlgshow(score1,score2);
        FreeLibrary(hdll);
}
return 0;
}
改一下,LoadLibrary和FreeLibrary都放在外面
#include <iostream>
#include <windows.h>
using namespace std;typedef void (*PFDlgShow)(int,int);
int main()
{
int score1,score2;
cout<<"本程序采用显式链接的方式测试开发MFC规则DLL\n";
HINSTANCE hdll;
PFDlgShow dlgshow;
hdll=LoadLibrary("..\\RegularDll.dll");
if (hdll!=NULL)
{
    dlgshow=(PFDlgShow)GetProcAddress(hdll,"ShowDlg");
}
while (true)
{ cout<<"请输入文化成绩:\n";
cin>>score1;
cout<<"请输入艺术成绩:\n";
cin>>score2;
dlgshow(score1,score2);
}
FreeLibrary(hdll);
return 0;
}他们有什么区别啊?感觉两种上第一种LoadLibrary会被执行,第二种一直oadLibrary都不会被执行
但是好像两种的FreeLibrary都会比LoadLibrary少执行一次啊,还有return 0;好像永远都没执行啊.
希望高手帮助解答