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

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

?? ??? ??????

??????

??? ?????? ??????? Visual Basic ????? ??? ?????? ??? ??????? ??? ????? ????? ??? ????? ????? ??????? ????? ??. ??? ???? ???? ??? ????? API ???? ????? ??? ?????????. ???? ??? ??????? ??????? Visual Basic ??????? ???? ?? ????? ??????? Visual Basic ?????? ??? ??? ?????????:

????? VarPtr - ????? ?????.

????? VarPtrArray - ????? ????.

????? StrPtr - ????? ?????? ?????? ?????? ???? UNICODE.

????? VarPtrStringArray - ????? ???? ?????.

????? ObjPtr - ?????? ??? ????? ?????? ???? ?????? ????? ????.

??????? ????

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

VarPtr

???? ??????? ??? ?????? ?????? ??? ????? ????? ?? ???? ????. ???? ??? ????? ?? ???? ???? ?????? ?????? ???????. ??? ???? ??? ???? ?? ???? ?? "????? ?????????" ??? ???????? ?? ???? reallocated ?????? Visual Basic ??? ??? ?? ???? ????? ???? ??? ??????? 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 ??? ???????:

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 ? ????? ??? SAFEARRAY (??? ?? ??? ???????) ??? ?????? VarPtrArray:

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

????: ?? ???? ??????? ?????? VarPtrArray ?????? ??? ????? ???? ????? ? ???? ???? Visual Basic ????? UNICODE/ANSI ?? ?????. ??? ??? ?????? VarPtrArray ??? ???? ????? ???? ?????? ??? ????? ???? ANSI ????? ?? ??????. ????? ?? ?????????? ???? ?????? VarPtrStringArray.

StrPtr

??? ????? ????? ?? Visual Basic ????? BSTR. ??? ??? ?????? ?? VarPtr ??? ????? ??? ????? ???? ?????? ??? ????? BSTR ??? ???? ??? ???? ???????. ?????? ??? ????? ?????? ?????? ?????? ???? ????, ????? ??? ??????? ?????? StrPtr. ???? ??? ?????? ????? ????? ????? ?? ???????. ??? ?? ???????? ??? ??? ????? ????? UNICODE ?? Visual Basic.

?????? ??? ????? ????? ????? ?? ????? ? ????? ????? ????? ??? ?????? StrPtr.

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

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

????? ??????? ??? ?????? ????? ????? ??? ????? ???? ??? ????? UNIOCODE ??? ??????? API.

VarPtrStringArray

???? VarPtrStringArray ????? ???? ?????. ????? ??????? UNICODE/ANSI ???? ?????? ?????? Visual Basic ????? ??????? ????? ?? ????? ???.

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

??????? 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);
   }
}
				

5.0 Visual Basic ????? ??? ??? ???? 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);
   }
}
				

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

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

???????? ?????? VarPtrStringArray ?? ??????? ????? ?? ????? ??? ????? ???? ??? ????? ????? ???? ??? ??????? ????.

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

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

ObjPtr

ObjPtr ???? ?????? ??? ????? ???? ?? ???? ??? ????? ????? ?????? ????? ?????? ??? ??????? ??????.

???? ????????? ???? ?? ??????? ??? ?????? ????? ????? ??? ????? ?????? ?? ????????. ?????? ?????? ???????? ????? IP ????? ?? ?????? ???????? ????? ?????? ??? ???? ???? ??? ?????? ?? walking ???????? ???????? ????. ?? ???? ?? ???????? ????? ???? ????? ??? ???????? ??? ???????? ??????.

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

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

???????

???? ???????: 199824 - ????? ??? ??????: 13/????? ??????/1425 - ??????: 2.1
????? ???
  • Microsoft Visual Basic 5.0 Learning Edition
  • Microsoft Visual Basic 6.0 Learning Edition
  • Microsoft Visual Basic 5.0 Professional Edition
  • Microsoft Visual Basic 6.0 Professional Edition
  • Microsoft Visual Basic 5.0 Enterprise Edition
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0
????? ??????: 
kbmt kbhowto KB199824 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????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