ʹÓÃVC±àдVBʹÓÃDLL
ʹÓÃVC±àдVBʹÓÃDLL
Ò»¡¢ÔÚº¯Êý¶¨ÒåÇ°±ØÐë¼ÓÉÏextern "c"£¬_stdcall¹Ø¼ü×Ö¡£
extern "C" int _stdcall Sum(int x,int y)
{
return x+y;
}
¶þ¡¢DLLµÄ.defÎļþÖбØÐë¼ÓÉÏÈë¿Úº¯Êý
EXPORTS
sample @1
sampleÊÇÄãÒªÔÚVBÖе÷Óõĺ¯ÊýÃû£¬@1±íʾ¸Ãº¯ÊýÔÚDLLÖеıàºÅ
Èý¡¢Òª×¢ÒâDLLÖеĺ¯ÊýºÍVBÖеĺ¯ÊýÉùÃ÷ÔÚÃû³Æ¡¢·µ»ØÀàÐÍ¡¢²ÎÊýÀàÐÍ¡¢²ÎÊý¸öÊýµÈ·½Ãæ±ØÐëÍêÈ«Ïàͬ£¬ÓÈÆäҪעÒâ´óСдµÄÎÊÌâ¡£
×¢ÒâÊÂÏ
1¡¢±ØÐë±£Ö¤VBºÍVCµÄ²ÎÊý¸öÊýÏàͬ£¬²ÎÊýËùÕ¼×Ö½ÚÊýÒ²Ò»ÖÂ
3£®Êý×é²ÎÊýÔÚDLLÖеĴ«µÝ
¡¡¡¡ÓÉÓÚDLL¾³£ÓÃÀ´½øÐÐһЩµ×²ãµÄÔËËã²Ù×÷£¬Òò´ËÓ¦ÓóÌÐò³£ÐèÒª´«µÝ´óÁ¿µÄÊý¾Ý¸øDLL¡£ÔÚC++ÖУ¬Ö¸ÕëÊǽøÐÐÊý×é²Ù×÷µÄ×î¼ÑÑ¡Ôñ£¬µ«VBÖÐûÓÐÖ¸ÕëµÄ¸ÅÄî¡£Õâͨ³£¿ÉÓÃÁ½ÖÖ·½·¨À´½â¾ö¡£
¡¡¡¡ÆäÒ»£¬ÔÚVBÖÐÉùÃ÷DLLʱ£¬ÓÃbyrefÀ´´úÌæbyval£¬¼´¿É½«Êý×éÖ¸Õë´«µÝ¸øDLL¡£
¡¡¡¡ÁíÍ⣬½«Êý×éÉùÃ÷Ϊ±äÌåÐÍ£¨variant£©£¬¼´¿ÉÖ±½Ó½«Êý×é´«µÝ¸øDLL¡£
ËÄ¡¢ÔÚvbÖÐÉùÃ÷£¨"dllTest.dll" ʹÓõÄÊÇÏà¶Ô·¾¶£¬Äã¿ÉÒÔ½«dll.dll·Åµ½.exeËùÔÚµÄĿ¼»òϵͳĿ¼£©£¬º¯ÊýÃû´óСÃô¸Ð
Private Declare Function Sum Lib "dllTest.dll" (ByVal x As Long, ByVal y As Long) As Long
Îå¡¢Àý×Ó
1¡¢Ð½¨Ò»¸öwin32 dynamic library,¿ÕµÄ¹¤³Ì
2¡¢Ð½¨Ò»¸ödllTest.cpp Îļþ,²¢Ìí¼Óµ½¹¤³Ì¡£ÄÚÈÝÈçÏÂ
// dll4.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
extern "C" int _stdcall Sum(int x,int y)
{
return x+y;
}
extern "C" int _stdcall GetNum(int Num) /*¾ßÌåʵÏÖ*/
{
return Num;
}
// dll4.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
Ïà¹ØÎĵµ£º
VBÖд´½¨µÄDLLÖ»ÊÇCOM×é¼þ£¬ÎÞ·¨×÷ΪÊä³öº¯ÊýµÄDLL¡£½ñÌì´ÓÅóÓÑÄÄÀï¸ãµ½Ò»ÖÖ¿ÉÒÔ´´½¨Êä³öº¯ÊýµÄDLLµÄ·½·¨£¬ÐÀϲ֮Ó࣬²»¸Ò¶ÀÏí£¬ÏÖÔÚ°ÑËû½éÉܸø´ó¼Ò¡£
¡¡¡¡VB±àÒëÎļþʵ¼ÊÉϲÉÈ¡ÁËÁ½´Î±àÒëµÄ·½·¨£¬Ê×ÏÈÊǵ÷ÓÃc2.exe²úÉúOBJÎļþ£¬È»ºóµ÷ÓÃLink.exeÁ¬½Ó¡£Èç¹ûÔÚlinkµÄʱºòÌí¼ÓEXPORTÑ¡Ïʵ¼ÊÉÏÊÇ¿ÉÒÔÊä³öº¯ÊýµÄ¡£µ«ÊÇ£¬ÔÚV ......
ºÜ¾ÃÒÔÇ°µÄÒ»¸ö´úÂëÁË¡£¡£¡£¡£¡£ÄÇʱ»¹³ÁÃÔÓÚÑо¿WindowsXPµÇ¼ÃÜÂëµÄ¼ÆËã·½·¨¡£¡£¡£¡£
ÏÈн¨Ò»¸öVB¹¤³Ì£¬»Ò»¸öCommandButton£¬¸ÄÃûΪcmdGetSYSKEY£¬»Ò»¸öTextBox£¬¸ÄÃûΪtxtSYSKEY£¬È»ºóÕ³ÌùÏÂÃæµÄ´úÂ룬ÔËÐм´¿É£¬ÔÚWindowsXP SP2 Build 2600 + VB6.0 SP6ϲâÊÔͨ¹ý£¬»ñµÃµÄSYSKEYÓëCain&Abel v4.9.6Ò»Ö¡£¡£¡£¡£ ......
´«Í³·½·¨ÊDZéÀúÒ»±é
Èç¹ûlistbox ÏîÄ¿¹ý¶à
Ã÷ÏÔËٶȲ»ÐÐ
ºÃ·½·¨ÊÇͨ¹ýsendmessge·¢ÏûÏ¢¸ølistboxÈÃËû°ÑÑ¡ÖÐÏîÄ¿Ö±½Ó´«µ½²ÎÊýÊý×éÖÐ
You can use the SendMessage() API function instead.
As
you probably know, this function lets you send a message to one or more
windows. The declaration statement conforms ......
½ñÌì×öÒ»¸öVB³ÌÐòµÄ×ÔÏÔ×¢²áÂë¡£ÎÒÒ²²»ÖªµÀ¸ÃÔõô½Ð£¬¾ÍÊÇÕÒµ½³öÏÖ×¢²áÂëµÄµØ·½£¬È»ºóÓöԻ°¿òµ¯³öÀ´¡£Ëµ°×Á˾ÍÊÇÓÃMessageBox°ÑÒ»¸ö×Ö·û´®¸øµ¯³öÀ´£¨Ã»×·Ç󰢡£¡£¡££©
ΪÁËÓеã×·Ç󣬽ñÌì²»µ¼Èëuser32ÀïÃæµÄAPI£¬¶øÊÇ°ÑVBÀïÃæ×Ô´øµÄMsgboxº¯Êý¸øÍÚ³öÀ´µ÷Ó㬾ÍÊÇÒýÓÃMSVBVM60.rtcMsgBoxº¯Êý¡£ÎÒÊ ......
VB¶ÔINIÎļþ²Ù×÷
2009-02-25 00:17
INI ÎļþÊÇʲôÑù×Ó£¿——²»»á°É£¬Õⶼ²»ÖªµÀ¡£INI Îļþ¾ÍÊÇ Windows Öг£¼û
µÄÒÔ .ini ΪÀ©Õ¹ÃûµÄÎļþ£¬ÆäÄÚ²¿¸ñʽºÍ¸÷²¿·ÖµÄÃû³ÆÈçÏ£º
[Section1]
Key1=Value1
Key2=Value2
Key3=Vlaue3
[Section2]
Key1=Value1
Key2=Value5
Key4=Value4
Key5=...
...
& ......