using a UDT in multiple applications
I have a DLL that has a UDT in it for employee
so it looks something like this
Public Type udtEmp
FirstName as string
LastName as string
EmpID as Long
End Type
etc...
anyways.. so i create the udt object in the first application.. and in the dll there is a public method to fill the udt with data using the userid which is passed to the method.. so i have a second exe that is called from the first one.. is there a way to get the variable info for the UDT in the second app from the first one.. like copying it from memory or something? right now i use command line params to pass the userID to child apps and run the dll's method again to fill a new UDT var in the child exe.. but i am trying to make my app more efficient.. what do you guys think?
Just can't stay out! Can I?
Duncan: Variable Length strings in the UDT? How will the "length" in the function get its value?
Both the apps need to have an uber-UDT to handle them, with the values in one element, and the lengths in another and pass them to the second app for restructuring.
It's sunny yet disturbingly windy...Does not make sense!
Now, if I wanted to pass a byte array, would I use the following:
VB Code:
Public Type mtypDataStruct
Pointer As Long
Length As Long
End Type
Now say I have a byte array:
From this byte array I can find the starting memory address:
VB Code:
Dim udtDS As mtypDataStruct
Pointer = VarPtr(Fish(0))
and it's length:
VB Code:
Length = UBound(Fish) + 1
Now since the data structure UDT is a constant fixed length I can literally pass ONLY the start address of this using SendMessage, oh and along with the hWnd where it is located.
From this when when the message is received, in the WinProc function, I can get the pointer and length for the data struct, from the other process memory, which in turn will let me reconstruct my byte array...
Is this the correct way to pass I byte array between applications, using Mirrions tutorial?
woKa
I had a pet fish once...then the snapper turtle ate it *SOB*
rlwhealdon,
There is one draw back to your little plan...
VB Code:
objApp2.HereIsSomeData(uBuffer.Data)
:D
How are you going to do this?
These apps are not ActiveX EXE's and should not have ANY references to each other, which you can't do unless one is an ActiveX EXE or DLL, which they are not.
Plus, the apps are is different threads...
MailSlots work OK, but have a few draw backs. Mellons code works like a treat, but is slightly longer and more complex and, during development, is prone to getting VB to set to self destruct :D
It is very rare in VB to pass data between 2 EXE's, which is why there is no KISS method :(
Sleepy Woka