FROM MSDN ONLINE:
Getting the Address of a Variable of User-Defined Type
An API programmer often needs to get the address of a variable of user-defined type. Consider, for example, the structure:Type utExample
   sString As String
   iInteger As Integer
End TypeDim uEx As utExampleSuppose we want to find the address of the variable uEx. First, note that the address of a structure variable is the same as the address of its first member. Now consider the following code:Debug.Print VarPtr(uEx)
Debug.Print VarPtr(uEx.sString)
Debug.Print VarPtr(uEx.iInteger)
Debug.Print
Debug.Print rpiVarPtr(uEx)
Debug.Print rpiVarPtr(uEx.sString)
Debug.Print rpiVarPtr(uEx.iInteger)whose output is as follows. 1243836 
 1243836 
 1243840  1243824 
 1243820 
 1243840
 
As you can see, VarPtr reports the address as you would expect: the address of uEx is the same as the address of uEx.aString, and the address of uEx.iInteger is 4 bytes larger, to account for the 4-byte BSTR.On the other hand, the rpiVarPtr is susceptible to BSTR-to-ABSTR translation, which occurs on the member of the structure that is a BSTR. The relationship between the first and second address in the second group may look strange until we remember that each call to rpiVarPtr produces a translation, so we cannot compare addresses from two separate calls, both of which involve translations!On the other hand, the third address is the address of the original integer member. There is no translation in the call:Debug.Print rpiVarPtr(uEx.iInteger)because there are no BSTR parameters. Thus, we can use an external function such as rpiVarPtr to compute the address of a structure provided the structure has at least one non-BSTR parameter. In this event, we get the address of one such parameter and count backwards to the beginning of the structure.

解决方案 »

  1.   

    风马牛不相及
     qixg(⊙∠⊙) (
      

  2.   

    修改数组的SafeArray结构模拟指针
    http://www.csdn.net/develop/author/netauthor/AdamBear/我用模拟指针技术写的图像Alpha淡入淡出演示程序,能达到与系统API函数统级别的速度(请运行编译后的exe)
    帖子:http://expert.csdn.net/Expert/topic/1104/1104910.xml?temp=.6940882
    下载:http://cocgame.myetang.com/zyl910/map/alphademo.zip
      

  3.   

    zyl910(910:分儿,我来了!) :
    我想读指定地址的内存指定。。只要系统允许访问,就能访问。
      

  4.   

    什么是物理内存地址呀??win32内存都是virtual 的。
    你的VC代码贴出来吧。我帮你翻译了。
      

  5.   

    : viperstorm(你也真调皮呀) 
    那你试一下 &H10000
      

  6.   

    有点难度哦。。
    我也已经开始着手解决了。。 zyl910(910:分儿,我来了!) 
    说实话,你那程序。。还不错。。但那种共享的精神,更值得我们学习。
      

  7.   

    对于修改绝对地址的物理内存,vb是办不到的,vc实现也是很麻烦的
      

  8.   

    TO:ziyue(紫月)
    &H10000 只是本进程的一个内存地址,跟物理内存的地址没什么关系。
    你的VC代码贴出来吧。我看看。
      

  9.   

    viperstorm(你也真调皮呀) 
    你用过C++吧。。
      

  10.   

    请分清虚拟内存地址和物理内存地址
    Windows程序是以保护模式运行的,每个进程都有自己独立的4GB的进程空间(因为一个32位指针的最大值就是4GB),这就是虚拟内存。虚拟内存地址不是物理内存地址!!!viperstorm(你也真调皮呀) 是对的。
      

  11.   

    物理内存地址只有工作在特权级的代码才有办法访问..
    不要说VB,就算是VC,如果不利用系统的bug,并且不写驱动,都是没办法做到的.