Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / September 2004

Tip: Looking for answers? Try searching our database.

DDE in C# .NET

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
M K - 07 Sep 2004 11:34 GMT
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?
Ben Schwehn - 07 Sep 2004 11:58 GMT
> I've got this code:
> (Library GMDDE.dll)
[quoted text clipped - 41 lines]
> Compilation is successfull, but I get an exception:
> System.NullReferenceException in GMDDE.dll (line: ...DDEInitialize...)

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
Signature

Ben
http://bschwehn.de


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.