DDEML Wrapper in C# in progress

  • Thread starter Thread starter Homa
  • Start date Start date
H

Homa

Hi all,

I'm writing a DDEML Wrapper in C#. I won't able to make a complete
wrapper because my application doesn't need to the full feature of
DDEML, espically the server part. Do anyone interested in working on
it? I would be happy to share the source code and improve it together.

Right now the source code is in two files: dmlModule.cs and
dmlException.cs
I'm using the Microsoft.ApplicationBlocks.ExceptionManagement for
error logging for the client application of this module (i.e., the
dmlExceptions are inherited from the baseApplicationException from the
MABEM).

The wrapper right now can handle client sync POKE and REQUEST
(actually that's all I need). If that's all you need, you can use it
as is unless there are bugs need to be fixed.


Where can I share the source code? It seems to be too long to just
post them here in text.


Oh, there is one question I have in mind right now.

for the ddeCallback, right now my signature is

public delegate int callbackHandler(UInt32 uType, UInt32 uFmt, IntPtr
hconv, IntPtr hsz1, IntPtr hsz2, IntPtr hdata, IntPtr dwData1, IntPtr
dwData2);

I'm using int as the return type. In the documentation, the return
value can be bool, flag, datahandle, or simply ignored.
Do you favor in using IntPtr or int in this case?

Happy Coding,
Homa Wong
 
Another question:

For the ddeClientTransaction, all three signature below works fine.

internal static extern IntPtr DdeClientTransaction(IntPtr pData, int
cbData, IntPtr hConv, IntPtr hszItem, ClipboardFormats wFmt,
TransactionTypes wType, int dwTimeout, int pdwResult);

internal static extern int DdeClientTransaction(ref byte pData, int
cbData, int hConv, int hszItem, int wFmt, int wType, int dwTimeout,
ref int pdwResult)

internal static extern IntPtr DdeClientTransaction(string pData, int
cbData, IntPtr hConv, IntPtr hszItem, ClipboardFormats wFmt,
TransactionTypes wType, int dwTimeout, int pdwResult);

What I want to point out is the type of the pData (first argument).
I'm using the third one for my request and poke (string pData) because
I'm just passing strings around.

But I think the second and third signatures have security problem
because you are passing a pointer of data in your heap to some other
apps. Can the other apps modify the pointer and do harm to my
application?

The first implementation is the best one because the data your want to
pass is copied to the memory in the dde, so the worst thing the other
apps can do is to read/write on the dde memory.

Or does dde has mechanism that prevent this happening and make all
three signature safe?

Homa Wong
 
Homa,

I would be interested in seeing your code. I have the dilemma of
talking to a DDE server ( the author doesn't have the time to move to
a newer technology) and want to move to using C#. I would appreciate
it if you would zip it up and send it as an attachment to
(e-mail address removed).

Thanks Bill
 
I just found out another problem about using DDE.

In certain situation, the DdeConnect would not return. So I need some
way to make a timeout for that. Is there a clean way to do this in C#?
What I could think of is start a timer and throw an exception when it
expires.

This problem occurs outlook.exe bug appears. The bug I am talking
about it sometimes there are instance(s) of outlook.exe stays in
memory and you have to terminate it by killing the process using task
manager. When one of these instances exists, it seems to block access
to the DdeConnect.

The DdeCreateStringHandle works fine, just DdeConnect fails. I don't
know if other functions has problem too.

Any thought is welcome,

Sorry for this messy message...

Homa Wong
 
Back
Top