VB 6.0 µ÷ÓÃdllµÄÎÊÌâ - .NET¼¼Êõ / VB.NET
ÎÒÔÚVC 6.0ÖÐдÁËÒ»¸öexample.dll£¬ÀïÃæÒ»¸öº¯Êý
extern "C" __declspec(dllexport)
HRESULT __stdcall Connect(LPCSTR IpAddr)
{
...
}
example.dllÖиú¯ÊýÃû³ÆΪ _Connect@4 £¨ÓÃdepends¹¤¾ß²é¿´£©
ÎÒÔÚVB 6.0Öе÷Óô˺¯Êý
Private Declare Function Connect Lib "example.dll" Alias "_Connect@4" (ByVal IpAddr As String) As Long
Dim result As Long
result = Connect("138.139.0.230")
If result <> 0 Then
MsgBox ("error_connect")
Else
MsgBox ("connect_ok")
End If
½á¹û·µ»Ø¶¼ÊÇ·Ç0£¬Á¬½Óʧ°Ü¡£
µ«ÎÒÓÃVC±àдµÄ´úÂëÒÔ¼°ÓÃVB.NET±àдͬÑù¹¦ÄܵĴúÂ붼¿ÉÒÔÁ¬½ÓÉÏ¡£
²»ÖªµÀÕâ¶ÎVB 6.0µÄ´úÂëÓÐʲô²»¶ÔµÄµØ·½¡£
£¨Ö»ÓÐ45·ÖÁË£¬È«É¢ÁË£©
VB.NETºÍVCµ÷ÓÃʱ£¬example.dllûÓмÓ__stdcall¡££¨ÒòΪVB 6.0ÐèÒªÊÇstdcall£©
¼´£º
extern "C" __declspec(dllexport)
HRESULT Connect(LPCSTR IpAddr)
{
...
}
VB.NET´úÂëÈçÏ£º
Imports System.Runtime.InteropServices
<DllImport("./example.dll", CallingConvention:=CallingConvention.Cdecl)> _
Public Function Connect(ByVal IpAddr As String) As Integer
End Function
Dim result As Integer
result = Connect("138.139.0.230") 'Á¬½Óµ¥°å
If result &
Ïà¹ØÎÊ´ð£º
vbÖÐ ÏÖÔÚÎÒÒª°ÑÊý¾Ý¿âÀï´æ´¢µÄÒ»¸ö¸½¼þµÄÄÚÈÝÌæ»»ÁË£¬Ôõô×ö£¬Ö»ÊÇÌæ»»ÎÒÖ¸¶¨µÄλÖ㬲»ÊÇÈ«²¿Ìæ»»
Ç뽫ÎÊÌâ˵Ã÷°×£¬´æ´¢×ֶθñʽ£¬Èç¹ûÊÇBinary¸ñʽµÄ±È½ÏÂé·³£¬Èç¹ûÊÇ×Ö´®£¬Ö±½ÓÌæ»»¡£×îºÃ²»Òª½øÐÐÖ¸¶¨Î»ÖÃÌæ»»¡ ......
Êý¾Ý¿âÀïÓÐÒ»¸ö×ֶεÄÄÚÈÝÊǶþ½øÖÆ£¬Ôõô²ÅÄÜ°ÑÕâ¸ö¶þ½øÖƶÁ³öÀ´
ʹÓÃ×Ö½ÚÁ÷¶ÔÏó¿ÉÒÔʵÏÖ
ÀýÈçÏÖÔÚÊý¾Ý¿âÀïÓиö×ֶεÄÄÚÈÝÊÇ0x504B03040A0000000800407F263C3B02465390000000820000000A0000006273CECACCE22E7478 ......
ÏÖÔÚÓиöxmlÎļþÊÇ<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xm ......
ÎÒµÄÒªÇóÊÇ£ºÍ¨¹ýץȡ±ðµÄ³ÌÐòÉϵıí¸ñµÄ¾ä±ú£¬È»ºó¶ÁÈ¡Õâ¸ö±í¸ñµÄÄÚÈÝ¡£
±í¸ñ¾ä±ú£¨ÀàÃû£ºMSFlexGridWndClass£©ÎÒÒÑ×¥µ½£¬½ÓÏÂÀ´ÈçºÎ¶ÁÈ¡±í¸ñµÄÄÚÈݾͲ»»áÁË£¿ÇóÖú¡£
ÄÜ°Ñ´úÂë·¢À´Ñ§Ï°Ï²»£¿
244326867@qq.com ......