troubleshooting Question

C# and User32.dll

Avatar of campbel8
campbel8 asked on
4 Comments1 Solution1708 ViewsLast Modified:

I am attempting to connect to DDE applications via C#. I have successfully written the code that imports the method, in addition, I have successfully launched the application, I have however been unsuccessful in connecting to it via DDE. I have included my code below, does anyone have any suggestions?

If feel I should note that I have debugged the code and I have noticed that sPtr, tPtr, and channel all include a value of 0 after their line of code is executed.

[DllImport("user32.dll", EntryPoint="DdeConnect")]
private static extern IntPtr DdeConnect(uint idInst, IntPtr hszService, IntPtr hszTopic, IntPtr pCC);

[DllImport("user32.dll", EntryPoint="DdeCreateStringHandle")]
private static extern IntPtr DdeCreateStringHandle(uint idInst, string psz, int iCodePage);

// This code is in a method
uint instId = 0;
IntPtr sPtr = DdeCreateStringHandle(instId, "iexplore", 1004);
IntPtr tPtr = DdeCreateStringHandle(instId, "www_openurl", 1004);

Process application = new Process();
application.StartInfo.FileName = @"C:\Program Files\Internet Explorer\iexplore.exe";            
IntPtr channel = DdeConnect(instId, sPtr, tPtr, (IntPtr)null);

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros