Getting information from unmanaged code??

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I am using a third party "dll" for my project(academic).

Some of the methods in this "dll" use "callback" mechanism.

For example, one method call "Receive(char *someStr, callback cb).

This method receives some messages asyncronously from other sources in
the system. Whenever the received message matches "someStr", it will
call callback method "cb" in the managed code. Received message contains
some other information along with a string. This string will be matched with
"someStr".

But it seems that .NET CF has no support for Callbacks.

Now, is there any way that we can get the information from unmanaged
code.

Kindly let me know,

Cheers,

Naveen.
 
Yes it is possible, but you'll need to use a native dll to provide the
actual callback method and then use a communication method of your choosing
to pass the data over to your managed code such as broadcasting a window
message you have registered with RegisterWindowMessage and then use a
MessageWindow control to catch this message in your managed application.
There are also a number of other methods to exchange data including Memory
mapped files, see Alexs article here : -
http://blog.opennetcf.org/ayakhnin/PermaLink.aspx?guid=abc9dafe-4199-46c7-8937-aa918311261d

Daniel Moth has posted an interesting compare and contrast article here
showing different methods of interprocess communication:-
http://www.zen13120.zen.co.uk/Blog/2004/09/ipc-with-cf-on-ce-part-1.html
http://www.zen13120.zen.co.uk/Blog/2004/09/ipc-with-cf-on-ce-part-2.html

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

Do have an opinion on the effectiveness of Microsoft Windows Mobile and
Embedded newsgroups? Let us know!
https://www.windowsembeddedeval.com/community/newsgroups
 
Hi Peter,

Thanks for your response. As a novice in .NET Compact Framework,
I couldn't quite get the point. Especially, the following lines,
but you'll need to use a native dll to provide the
actual callback method and then use a communication method of your choosing
to pass the data over to your managed code

do I need to write a new dll which generates a windows message containing
the actual information from the existing method which uses callback ?!!

Could you please let me know more about registering windows messages.
Could you also suggesting me a starting point for these issues.

Cheers,

Naveen.
 
Yes, because you can't expose a callback method from .NETCF code.
Registering window messages is very simple, you call the
RegisterWindowMessage function with a string specific to your message for
example "myapp.callback" as long as you use the exact same string in both
your native dll and your .NETCF code you will get the same message id
returned.
There is an example here of using the MessageWindow control in your .NETCF
code:-
http://samples.gotdotnet.com/quickstart/CompactFramework/doc/messagewindow.aspx

You'll find a number of the methods you'll need to P/Invoke are already
available in the OpenNETCF Smart Device Framework
www.opennetcf.org/sdf/) - the Win32Window class includes
RegisterWindowMessage and many other API functions.

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

Do have an opinion on the effectiveness of Microsoft Windows Mobile and
Embedded newsgroups? Let us know!
https://www.windowsembeddedeval.com/community/newsgroups
 
Hi Peter,

Thanks for your reply. Now it is clear for me.

As a novice in using MS Visual Studio.NET 2003 and
.NET Compact Framework, I don't have much knowledge
in writing dlls.

Could you please suggest me a good starting point for writing
dlls using MS Visual Studio.NET 2003 and 'C' language.

What is the procedure I need to follow.

Kindly let me know.

Cheers,

Naveen.
 
Back
Top