D
Dale
I'm trying to use the DdeInitialize() function from an external DLL in my C#
code. The first parameter is described as LPDWORD, which seems to be a
pointer to a DWORD. I believe that the DWORD is equivalent to UInt32.
The MarshalAs attribute does not seem to have a pointer type available. How
do I pass an integer pointer to the external DLL function?
I've attached the code I have so far below.
Thanks for any suggestions.
Dale
[System.Runtime.InteropServices.DllImport("User32.DLL")]
public static extern System.UInt32 DdeInitialize(
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.Unm
anagedType.U4)]
System.UInt32 pidInst, //LPDWORD pidInst,
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.Unm
anagedType.FunctionPtr)]
DDE_CallBack_delegate pfnCallback, //PFNCALLBACK pfnCallback,
System.UInt32 afCmd, //DWORD afCmd,
System.UInt32 ulRes //DWORD ulRes
);
public static int Send_Message_To_Toolbox_Server(string as_Command_Line)
{
System.UInt32 lui32_rc;
System.UInt16 lui16_App_Instance_Id;
System.IntPtr lptr_App_Instance_Id;
System.UInt32 lui32_afCmd;
System.UInt32 lui32_ulRes;
const System.UInt32 APPCMD_CLIENTONLY = (System.UInt32)0x00000010L;
// APPCMD_CLIENTONLY 0x00000010L
// Declare and get pointer to callback function
DDE_CallBack_delegate myDelegate = new
DDE_CallBack_delegate(DDEMLWrapper.ApplicationLauncher_DdeCallback);
// Initialize this application for DDE communication
lui16_App_Instance_Id = 0;
lptr_App_Instance_Id = (System.IntPtr)lui16_App_Instance_Id;
lui32_afCmd = APPCMD_CLIENTONLY;
lui32_ulRes = 0;
lui32_rc = DdeInitialize(lptr_App_Instance_Id, myDelegate, lui32_afCmd,
lui32_ulRes);
// Send as_Command_Line to the server
return 0;
}
code. The first parameter is described as LPDWORD, which seems to be a
pointer to a DWORD. I believe that the DWORD is equivalent to UInt32.
The MarshalAs attribute does not seem to have a pointer type available. How
do I pass an integer pointer to the external DLL function?
I've attached the code I have so far below.
Thanks for any suggestions.
Dale
[System.Runtime.InteropServices.DllImport("User32.DLL")]
public static extern System.UInt32 DdeInitialize(
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.Unm
anagedType.U4)]
System.UInt32 pidInst, //LPDWORD pidInst,
[System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.Unm
anagedType.FunctionPtr)]
DDE_CallBack_delegate pfnCallback, //PFNCALLBACK pfnCallback,
System.UInt32 afCmd, //DWORD afCmd,
System.UInt32 ulRes //DWORD ulRes
);
public static int Send_Message_To_Toolbox_Server(string as_Command_Line)
{
System.UInt32 lui32_rc;
System.UInt16 lui16_App_Instance_Id;
System.IntPtr lptr_App_Instance_Id;
System.UInt32 lui32_afCmd;
System.UInt32 lui32_ulRes;
const System.UInt32 APPCMD_CLIENTONLY = (System.UInt32)0x00000010L;
// APPCMD_CLIENTONLY 0x00000010L
// Declare and get pointer to callback function
DDE_CallBack_delegate myDelegate = new
DDE_CallBack_delegate(DDEMLWrapper.ApplicationLauncher_DdeCallback);
// Initialize this application for DDE communication
lui16_App_Instance_Id = 0;
lptr_App_Instance_Id = (System.IntPtr)lui16_App_Instance_Id;
lui32_afCmd = APPCMD_CLIENTONLY;
lui32_ulRes = 0;
lui32_rc = DdeInitialize(lptr_App_Instance_Id, myDelegate, lui32_afCmd,
lui32_ulRes);
// Send as_Command_Line to the server
return 0;
}