📄 subject_65561.htm
字号:
<p>
序号:65561 发表者:wuzhang 发表日期:2003-12-18 13:10:21
<br>主题:那位大侠有GetProcAddress()这个函数的例子?
<br>内容:那位大侠有GetProcAddress()这个函数的例子?急用!!!
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:BigJames 回复日期:2003-12-18 13:27:08
<br>内容:MSDN上有啊!<BR><BR>===============================================<BR>The following example illustrates an important difference between run-time and load-time dynamic linking. If the MYPUTS.DLL file is not available, the application using load-time dynamic linking simply terminates. The run-time dynamic linking example, however, can respond to the error.<BR><BR>// File: RUNTIME.C<BR>// A simple program that uses LoadLibrary and <BR>// GetProcAddress to access myPuts from MYPUTS.DLL. <BR> <BR>#include <stdio.h> <BR>#include <windows.h> <BR> <BR>typedef VOID (*MYPROC)(LPTSTR); <BR> <BR>VOID main(VOID) <BR>{ <BR> HINSTANCE hinstLib; <BR> MYPROC ProcAdd; <BR> BOOL fFreeResult, fRunTimeLinkSuccess = FALSE; <BR> <BR> // Get a handle to the DLL module.<BR> <BR> hinstLib = LoadLibrary("myputs"); <BR> <BR> // If the handle is valid, try to get the function address.<BR> <BR> if (hinstLib != NULL) <BR> { <BR> ProcAdd = (MYPROC) GetProcAddress(hinstLib, "myPuts"); <BR> <BR> // If the function address is valid, call the function.<BR> <BR> if (NULL != ProcAdd) <BR> {<BR> fRunTimeLinkSuccess = TRUE;<BR> (ProcAdd) ("message via DLL function\n"); <BR> }<BR> <BR> // Free the DLL module.<BR> <BR> fFreeResult = FreeLibrary(hinstLib); <BR> } <BR> <BR> // If unable to call the DLL function, use an alternative.<BR> <BR> if (! fRunTimeLinkSuccess) <BR> printf("message via alternative method\n"); <BR>}<BR>Because the program uses run-time dynamic linking, you should not link with the import library when creating the program module.<BR><BR><BR><BR>===============================================
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:绩奇 回复日期:2003-12-20 17:17:31
<br>内容:帮忙解释一下上边的一些较难语句
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -