.NETGURU
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 Guru (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 Guru (http://www.dot-net-guru.com/)

<Id>2M1SkVqmckmvG826tVif0A==</Id>
Reply to this message...
 
    
Ben Schwehn
M K via .Net Guru 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




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification