currently I am working on a small project, updating a softwarepackage from VB6 to VB.NET and a small DLL, writen in VC6 updating to the latest Visual Studio Version.
Now I have a small problem: In VB6 is a Form application an die VC-Code defines two DLL-Files. For Communication between these to application, there was a shared memory like and a lot of other functions to communicate.
This is the Shared Memory Struct in C:
typedef struct MEMORY
{
double Mem0;
int Mem1;
short Mem2;
}MEMORY;
MEMORY *sharedStructMEMORY; // Creating a pointer.
//This is a function, I call out of VB:
void DLL_API __stdcall Fkt_get_memAddr (MEMORY *pnt_sharedmem)
{
sharedStructMEMORY = pnt_sharedmem;
};
Now lets have a look to the VB.NET Code: The Struct:
Public Structure MEMORY
dim mem1 as double
dim mem2 as int32
dim mem3 as short
end structure
The Function:
Public Class Dll1
<DllImport(Dll_Datei_1)> _
Public Shared Sub Fkt_set_memAddr(<MarshalAs(UnmanagedType.Struct)> ByRef sharedmem As MEMORY)
End Sub
End Class
now, if i call the Function like this:
public sharedMEM as MEMORY
Fkt_set_memAddr(sharedMEM)
The DLL should get the adress from the VB.NET struct, so that until now, I am able to write and read from the same memory.
But it does not work. Always when I set the first value from the memory in the DLL, while debuggig the DLL, it says the value is written correctly. If I check it in VB.NET, the value is like
2.5481197073372403e-307
Whats going wrong?
Thanks for help! Andi