Visual Basic ??? ?? ?? ??? ??????? ???? ????

???? ?????? ???? ??????
???? ID: 199824 - ?? ???????? ?? ?????? ??? ?? ?? ???? ???? ???? ??.
??? ?? ??????? ???? | ??? ?? ??????? ????

?? ????? ??

??????

?? ??, ???? ?????? ??? ?? ?? ???? ??????? ??????? ???? ?? ???????? ?? ??? ??? Visual Basic ?????????? ?? ??? ???????? ??? ???????, ??? ??? API ?????? ?? ??? ??????? ?? ???????? ??? ?? ???? ????? ???? ?? ?? ?? ??????? ??????? Visual Basic ?????????? ??? ?? ???? ?? ?? ????? Visual Basic ??????:

VarPtr - ?? ?? ??? ???? ???

VarPtrArray - ???? ?? ??? ???? ???

StrPtr - ??????? ???????? ??? ?? ??? ???? ???

VarPtrStringArray - ???????? ?? ???? ???? ?? ??? ???? ???

ObjPtr - ???? ?? ???? ???????? ?? ?????? ???????? ??????? ?? ??? ???? ???

???? ???????

???????:: ?? ????; ??? ?? ?? ???? ????? ???????? discussed ??? VarPtr, VarPtrArray, VarPtrStringArray, StrPtr, ObjPtr. Microsoft ?????? ?????? ?? ?? ??????? ??????? ???? ???? ?? Visual Basic ?????????? ??? ????? ???? ??? ?? "???? ??" ?? ???????? ???? ??? ??? ?? ??? Microsoft ?????? ???? ?? ?? Visual Basic ?? ?????? ????????? ??? ?????? ??????

VarPtr

?? ?????? ??? ?? ?? ???? ???? ?? ???? ?? ??? ?? ??????? ???? ?? ??? ????? ???? ?? ???? ??? ?? ?? ??? ?? ???? ???? ???????? ?? ??? ??? ???? ?? ?? ??? ???? ??? ???????, ?? ???? ????? ????? ???? ?? ???????? ???????? ???????? ?? ???? ?? reallocated Visual Basic ?????? ???? ?? ???? ???? careful ?? ?? ???? ???? ?? ???? ?? ??? ?? ??????? ???? ?? ??? VarPtr ?? ??????

????? ?????? ?? ?? ??? ??????? ???? ??:

Dim lngVariableAddress as Long
Dim dblMyVariable as Double
lngVariableAddress = VarPtr(dblMyVariable)
				

?? ?????? ??? ???? ???? ?? ???? ???? ?? ??? ??????? ???? ??:

Dim lngElementAddress as Long
Dim lngArrayOfLongs(9) as Long
' following will get address of 4th element
lngElementAddress = VarPtr(lngArrayOfLongs(3))
				

??????: VarPtr ?????? ???? ???? ?? ??? ?? ??????? ???? ?? ??? ????? ???? ???? ?? ???? ????? ???? ??????? ?? ??? VarPtrArray ?????? ??????

VarPtrArray

Visual Basic ??? ??????? SAFEARRAYs ?? ??? ??? ???????? ?? ???? ???? SAFEARRAY ?????? ?? ??? ?? ???, ???? VarPtrArray ?????? ?? ????? ???? ?? ???????? ??? ????? ??? Visual Basic 5.0 ?? Visual Basic 6.0 declarations respectively:

Declare Function VarPtrArray Lib "msvbvm50.dll" Alias "VarPtr" _
(Var() as Any) As Long


Declare Function VarPtrArray Lib "msvbvm60.dll" Alias "VarPtr" _
(Var() as Any) As Long
				

??? SAFEARRAY ?? ??? ?? ???, VarPtrArray ????? ???? ?? ??? SAFEARRAY ??? (????????? ????? ??) ???:

Dim lngSafeArrayAddress as Long
Dim lngArrayOfLongs(9) as Long
lngSafeArrayAddress = VarPtrArray(lngArrayOfLongs())
				

??????: VarPtrArray ?????? ???? ????, ?????????? ?? ??? ???? ?? ??? ?? ??????? ???? ?? ??? Visual Basic ?????????? ?? ??? ???????/ANSI ???????? ???? ?? ???????? ??? ?? VarPtrArray ?? ?????????? ?? ??? ???? ?? ????? ????, ?? ???? ?? ?? ??????? ANSI ????????? ?? ??? ??????? ??????? ???? ??????? ?? ??? VarPtrStringArray ?????? ??????

StrPtr

Visual Basic ??? ?????????? BSTR ?? ??? ??? ???????? ?? ???? ???? ??? ?? VarPtr ?? ???????? ?????? ?? ??? ?? ?? ????? ????, ?? BSTR, ???????? ?? ???? ???? ?? ???? ???? ?? ?? ?? ??? ??????? ??????? ???????? ??? ????? ?? ??? ?? ???, ???? StrPtr ?????? ?? ????? ???? ?? ???????? ??? ?? ?????? ???????? ?? ????? ???? ?? ??? ???? ??? ???? ?? ?????????? Visual Basic ??? ??????? ?? ??? ??? ???????? ?? ??? ?? ?????

???? ???????? ?? ????? ???? ?? ??? ?? ???, StrPtr ????? ???? ?? ??? ???????? ?? ????

??????::

Dim lngCharAddress as Long
Dim strMyVariable as String
strMyVariable = "Some String"
lngCharAddress = StrPtr(strMyVariable)
				

?? ???? ??? API ??? ???? ?? ??? ??? UNIOCODE ???????? ?? ??? ???? ?? ???? ?? ??? ???? ?? ??? ?? ?? ?????? ?? ????? ?? ?????

VarPtrStringArray

VarPtrStringArray ?????????? ?? ??? ???? ?? ??? ???? ??? Visual Basic ?????? ?? ?? intrinsic ???????/ANSI ??????? ?? ????, ?? ??? declaration ?????? ????????? ??? ????????? ???? ?? ???? ???

??????, .odl ??????? ?? ???? ?????? ????????? ?? ?????? ???? ?? ??? MIDL ??????? ?? ????? ?? ????

Visual Basic 6.0, ?? ??? ???? ?? ?? ??????? ?? ??? VB6ptrlib.odl ???? ?? ??? ????? ?????:

#define RTCALL _stdcall
[
uuid(C6799410-4431-11d2-A7F1-00A0C91110C3),
lcid (0), version(6.0), helpstring("VarPtrStringArray Support for VB6")
]
library PtrLib
{
importlib ("stdole2.tlb");
[dllname("msvbvm60.dll")]
module ArrayPtr
   {
   [entry("VarPtr")]
   long RTCALL VarPtrStringArray([in] SAFEARRAY (BSTR) *Ptr);
   }
}
				

Visual Basic 5.0, ?? ??? ???? ?? ?? ??????? ?? ??? VB5ptrlib.odl ???? ?? ??? ????? ?????:

#define RTCALL _stdcall
[
uuid(6E814F00-7439-11D2-98D2-00C04FAD90E7),
lcid (0), version(5.0), helpstring("VarPtrStringArray Support for VB5")
]
library PtrLib
{
importlib ("stdole2.tlb");
[dllname("msvbvm50.dll")]
module ArrayPtr
   {
   [entry("VarPtr")]
   long RTCALL VarPtrStringArray([in] SAFEARRAY (BSTR) *Ptr);
   }
}
				

????? ????? ?? ??? ??? Visual Basic 6.0 ?? Visual Basic 5.0 ?????? ????????? (.tlb) respectively MIDL ??????? ?? ???? .odl ??????? ?? ?????? ???? ?? ??? ????? ???? ????????? ?? ????? ????:

MIDL /t VB6ptrlib.odl MIDL /t VB5ptrlib.odl

???? ????????? ??? VarPtrStringArray ?????? ?? ????? ????, ???? ??? ?????? ?????? ????????? ?? ?? ???? ??? ????? ????? ?? ???????? ???

??????::

Dim MyArrayOfStrings(2) As String
Dim AddressOfArray As Long
MyArrayOfStrings(0)="AAA"
MyArrayOfStrings(1)="BBB"
AddressOfArray = VarPtrStringArray ( MyArrayOfStrings() )
				

ObjPtr

ObjPtr ???????? ?? ??? ??? ???? ???????? ?? ??? ???? ?? ?? ?? ???????? ?? ?????? ???????? ???????? ?? ??? obtains ???

?? ???? ???????? ?? ?????? ???? ?? ??? ?? ?????? ?? ????? ???? ?? ?? ???????? ??? ???????? ?? ??? ??? ????? ??? ?? ????? ?? ???????????, ?? ??????? ?? ???? ??? ?????? walking ?? ?? ????? ???? ??? ???????? ?? ??? ????? ????? ?????? ??? ?? ?????? ??? ???? ???????? ?? ??? ?? ???? ???????? thing ?? ??? ??? ?? ????? ?? ????? ???? ?? ????

??????::

objCollection.Add MyObj1, CStr(ObjPtr(MyObj1))
...
objCollection.Remove CStr(ObjPtr(MyObj1))
				

???

???? ID: 199824 - ????? ???????: 02 ?????? 2010 - ??????: 4.0
???? ???? ???? ??:
  • Microsoft Visual Basic 5.0 Learning Edition
  • Microsoft Visual Basic 5.0 Professional Edition
  • Microsoft Visual Basic 6.0 Professional Edition
  • Microsoft Visual Basic 5.0 Enterprise Edition
??????: 
kbhowto kbmt KB199824 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:199824

??????????? ???

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com