The CopyMemory function provides an easy way to perform the View access operator (*) in C + +, which accesses the value of the variable to which a pointer variable is directed.
If there is a pointer variable P, in C + + can simply use *p to access, that in VB how to access it?
In VB, we can use the CopyMemory function alias.
Declare Sub vbgettarget Lb "kernel32" Alias "RtlMoveMemory" (Target as Any,byval lpoint as Long,byval cbcopy as Long)
Dim Pointer as Long
Dim Target as Integer
Dim I as Integer
Pointer=varptr (i) ' Get pointers
Vbgettarget Target,pointer,lenb (Target)
For a long time, it has been assumed that only the functions in a standard DLL can be referenced through absolute paths. In fact, you can also use a relative path. It's simple, just try it now.
1) Absolute Path method
For example, your DLL file is located in C:\testDLL\debug\testDLL.dll
Generally speaking, you need to make the following statement in VB
Declare Sub mytest Lib "C:\testDLL\dubug\testDLL.dll" (ByVal x as Long)
Another workaround is to put the TestDLL.dll in the Windows system directory so that you can refer to the file name directly. However, the need to put a file in the Windows system directory, is very uncomfortable!
2) Relative Path method
See how we use relative paths, assuming your DLL file is located in C:\testDLL\debug\testDLL.dll, your VB program is located in the directory C:\testDLL\vbClient
You can make the following statement in VB program:
Declare Sub mytest Lib ". /dubug/testdll.dll "(ByVal x as Long)
If you run your VB program directly, the system will be prompted to error: Can not find. /dubug/testdll.dll.
In order to make the above statement its function, first temporarily closes your VB project. Then use a text editor (NOTEPAD,EDITPLUS,ETC) to open the engineering file (that is, the guy whose suffix is vbp), usually vbp files are made up of several parts.
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
and provide relevant evidence. A staff member will contact you within 5 working days.