以下是零基础学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;好像永远都没执行啊.
希望高手帮助解答
#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;好像永远都没执行啊.
希望高手帮助解答
解决方案 »
- VC2005如何设置编码区背景色
- 关于MessageBox和TextOut 的问题
- 为什么 Xtreme.Toolkit 中的 CXTPRibbonBar 创建不了?
- 直线的Hough检测中碰到的图像原点及直线角度问题
- 如何全屏显示图片,我获得了文件夹的值
- 帮忙看一下,很简单那
- 大家推荐几本好书给我????
- 如何象OutlookExpress中的ListCtrl一样,整行选中变蓝时,前几列图标不变蓝。解答150分,up有分
- help me !!!
- VBS如何正确地向VC的DLL函数传入STRING
- 温度采集中关于线程的问题
- 如何用VC开发类似远程桌面的软件,就是在局域网中能够看到别人的桌面并控制?
每次都是非正常退出的吧while (true)没有执行完,return 0;当然不会执行了。