Search:
Namespaces
Discussions
.NET v1.1
Feedback
DDE in C# .NET
Messages
Related Types
This message was discovered on
microsoft.public.dotnet.languages.vc
.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...
M K via .NET 247 (VIP)
I've got this code:
(Library GMDDE.dll)
namespace GMDDE {
delegate Int32 DDECall(Int32 uiType, Int32 uiFmt, Int32 hConv,
Int32 sz1, Int32 sz2, Int32 hData, Int32 lData1, Int32 lData2);
public class GMDDEClass {
[DllImport("user32", EntryPoint="DdeInitializeA")]
private static extern Int32 DdeInitialize(Int32 pidInst, DDECall pfnCallback,
Int32 afCmd, Int32 ulRes);
private const Int32 DMLERR_NO_ERROR = 0x0000;
private const Int32 APPCMD_CLIENTONLY = 0x00000010;
public bool InitDDE(Int32 hConv, Int32 lIdLocal) {
DDECall GMDDEDelegat = new DDECall(DDECallback);
if (DdeInitialize(lIdLocal, GMDDEDelegat, APPCMD_CLIENTONLY, 0) != DMLERR_NO_ERROR) {
return false;
}
else {
return true;
}
}
public static Int32 DDECallback(Int32 uiType, Int32 uiFmt, Int32 hConv,
Int32 sz1, Int32 sz2, Int32 hData, Int32 lData1, Int32 lData2) {
return 1;
}
}
}
and here is calling in another project:
(application ProdCat.exe)
...
GMDDE.GMDDEClass GMDDEInstance = new GMDDE.GMDDEClass();
Int32 hConv = 0;
Int32 lIdLocal = 0;
if (GMDDEInstance.InitDDE(hConv, lIdLocal) == false) {
MessageBox.Show("Wyst?pi? b??d podczas inicjalizacji DDE!",
"B??d inicjalizacji DDE",
MessageBoxButtons.OK,
MessageBoxIcon
.Error);
}
else {
MessageBox.Show("Inicjalizacja DDE powiod?a si?!",
"DDE zainicjowane",
MessageBoxButtons.OK,
MessageBoxIcon
.Information);
}
...
Compilation is successfull, but I get an exception:
System.
NullReferenceException
in GMDDE.dll (line: ...DDEInitialize...)
Where I make a mistake?
--------------------------------
From: M K
-----------------------
Posted by a user from .NET 247 (
http://www.dotnet247.com/
)
<Id>2M1SkVqmckmvG826tVif0A==</Id>
Reply to this message...
Ben Schwehn
M K via .NET 247 wrote:
[Original message clipped]
I believe the mistake is that DdeInitialize takes an pointer to an int,
not an int. You're then passing NULL as the pointervalue (Int32 lIdLocal
= 0;)
when the doc says that: At initialization, this parameter should
*point* to 0.
hth
--
Ben
http://bschwehn.de
Reply to this message...
System.NullReferenceException
System.Windows.Forms.MessageBox
System.Windows.Forms.MessageBoxButtons
System.Windows.Forms.MessageBoxIcon
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com