请问能否在VB中用WM_COPYDATA把一个Type(结构)类型的数据传递给VC进程??
像这样:COPYDATASTRUCT::lpData = aTypeVal
PS:COPYDATASTRUCT::lpData 要求的是一个PVOID (void*)
像这样:COPYDATASTRUCT::lpData = aTypeVal
PS:COPYDATASTRUCT::lpData 要求的是一个PVOID (void*)
解决方案 »
- EXE注入器,把DLL注入游戏后,创建窗体的问题
- VC++关于directshow图像旋转90度输出花屏的问题
- ::GetWindowRect( hWnd, &rc);ScreenToClient(&rc);和::GetClientRect(hWnd,&rc);是相等的吧?
- 定义了CALLBACK的TIMER函数,但是里面不能调用类中的其他函数,恳请各位老大帮忙
- 怎样使菜单变灰?
- 高手不要错过,还再加高分的,号小开不了大帖子,在线…………
- 哪儿有jpeg的分层压缩解压的c源码啊?
- 请问有没有能读出注册表一个项下所有子项的函数?太感谢了!
- 为什么要屏蔽背景擦除?
- 数据处理问题,利用点到直线的距离判断异常点,很菜的,快来抢分!!!!!!!!文件,数组,指针。。。
- 急求源码
- 怎样通过端口号(如tcp端口80)找到占用此端口的程序名如(qq.exe)
不知道。
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.MSDN索引varptr
结果:WM_COPYDATA消息是收到了,但是~lpData的数据是不对的(杂乱无章),LOOKPublic Function NotifyReceiveMsg(EncryptType As Integer, MsgType As Integer, MsgID As Long, Optional ErrorType As Integer = 0) As Long
If g_hwndParent <> 0 Then
Dim rm As TReceiveMsg
Dim cs As COPYDATASTRUCT
With rm
.EncryptType = EncryptType
.MsgType = MsgType
.MsgID = MsgID
.MsgType = ErrorType
End With
With cs
.dwData = NT_RECEIVE_MSG
.cbData = DL_RECEIVE_MSG
.lpdata = VarPtr(rm)
' With .lpdata
' .EncryptType = EncryptType
' .MsgType = MsgType
' .MsgID = MsgID
' .MsgType = ErrorType
' End With
End With
NotifyReceiveMsg = CopyDataSendMessage(g_hwndParent, WM_COPYDATA, g_hwndSelf, cs)
Else
NotifyReceiveMsg = -1
End If
End Function
当我这样调用函数的时候:NotifyReceiveMsg 3, 1, 12345, 0
接收程序得到的结果是:
lpData.EncryptType == -448
lpData.MsgType == 18
lpData.MsgID == 2082894080
lpData.ErrorType == 11161郁闷啊
用VARPTR()解决了~~~~~~~~~~
是我的错!!!!
万分感谢~~~~~~~请问如何给分????????????