📄 subject_17055.htm
字号:
<p>
序号:17055 发表者:ljf 发表日期:2002-10-07 22:51:42
<br>主题:请问,如何使用现成的DLL控件
<br>内容:比如我要做个图片浏览器,有现成的控件使用,如何才能放到我的资源里并进行控制?
<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>回复者:黄飚 回复日期:2002-10-08 08:22:19
<br>内容:1打开VC<BR>2打开你的项目文件<BR>3打开Project->Add To Project->Components and controls->有两个目录(一般选择Register Activex Controls)->选择你的控件->按照向导提示-》在你的Controls里会出现新的图标->往你的Dialog里放上该图标,-》你就可以用跟普通控件一样用了。<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>
回复者:徐景周 回复日期:2002-10-08 10:00:18
<br>内容:可参看下面内容:<BR><BR> 更方便有效的装载和使用DLL文件!<BR><BR><BR>How to load dynamic link librarys the easiest way instead of the long way <BR><BR>Introduction<BR>Have you ever got tired of loading Dynamic Link Libraries the long way, with the usual steps LoadLibrary, and GetProcAddress, then you have to check for each function address if they are NULL, and don't mention about casting the function pointer and hard ways that make your brain strain. And wish there was an easier way to get around things? Well this will just do that in a way and is about the easiest way I know of actually<BR><BR><BR>//GetProcAddresses<BR>//Argument1: hLibrary - Handle for the Library Loaded<BR>//Argument2: lpszLibrary - Library to Load<BR>//Argument3: nCount - Number of functions to load<BR>//[Arguments Format]<BR>//Argument4: Function Address - Function address we want to store<BR>//Argument5: Function Name - Name of the function we want<BR>//[Repeat Format]<BR>//<BR>//Returns: FALSE if failure<BR>//Returns: TRUE if successful<BR>BOOL GetProcAddresses( HINSTANCE *hLibrary, <BR>LPCSTR lpszLibrary, INT nCount, ... )<BR>{<BR>va_list va;<BR>va_start( va, nCount );<BR><BR>if ( ( *hLibrary = LoadLibrary( lpszLibrary ) ) <BR>!= NULL )<BR>{<BR>FARPROC * lpfProcFunction = NULL;<BR>LPSTR lpszFuncName = NULL;<BR>INT nIdxCount = 0;<BR>while ( nIdxCount < nCount )<BR>{<BR>lpfProcFunction = va_arg( va, FARPROC* );<BR>lpszFuncName = va_arg( va, LPSTR );<BR>if ( ( *lpfProcFunction = <BR>GetProcAddress( *hLibrary, <BR>lpszFuncName ) ) == NULL )<BR>{<BR>lpfProcFunction = NULL;<BR>return FALSE;<BR>}<BR>nIdxCount++;<BR>}<BR>}<BR>else<BR>{<BR>va_end( va );<BR>return FALSE;<BR>}<BR>va_end( va );<BR>return TRUE;<BR>}<BR><BR>So since we now have the main core to this article, lets now look at how to use this with a short sample that was compiled as a Windows console application.<BR><BR>#include <BR><BR>typedef int ( WINAPI *MESSAGEBOX ) <BR>( HWND , LPCSTR, LPCSTR, DWORD );<BR>typedef int ( WINAPI *MESSAGEBOXEX ) <BR>( HWND , LPCSTR, LPCSTR, DWORD , WORD );<BR><BR>void main(void)<BR>{<BR>MESSAGEBOX lpfMsgBox = NULL;<BR>MESSAGEBOXEX lpfMsgBoxEx = NULL;<BR>HINSTANCE hLib;<BR>if(GetProcAddresses( &hLib, "User32.dll", 2,<BR>&lpfMsgBox, "MessageBoxA",<BR>&lpfMsgBoxEx, "MessageBoxExA" ) )<BR>{<BR>lpfMsgBox( 0, "Test1", "Test1", MB_OK );<BR>lpfMsgBoxEx( 0, "Test2", "Test2", MB_OK, <BR>MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US ) );<BR>}<BR>if ( hLib != NULL )<BR>FreeLibrary( hLib );<BR>}<BR><BR><BR><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 + -