DLLImport - unmanaged modul |
Post Reply
|
| Author | |
pawl
Newbie
Joined: 2010-January-15 Location: Czech Online Status: Offline Posts: 3 |
Quote Reply
Topic: DLLImport - unmanaged modulPosted: 2010-February-04 at 14:18 |
|
I tried to load DLL system user32.dl and import function MessageBoxA - no problem run
(I tried only in virtualrob).I made library in Visual C++. Library was compiled for Win32. If I run in virtualrob, I'll copy into "\WINDOW" folder. But problem is coming when I want to run on real robot. Because on robot run WINCE. I don't know what version and kind of processor (ARM, x86 ... ) ( It isn't such problem. I have SDK for Win CE5) and next problem can be access WINDOW folder (or start path app) It possible to access other unmanaged library ? ![]() |
|
![]() |
|
carlosmtz2000
Senior Member
Joined: 2008-July-10 Location: United States Online Status: Offline Posts: 194 |
Quote Reply
Posted: 2010-February-08 at 16:54 |
|
Hi,
Windows CE holds functions in different dlls. A lot of these functions are defined inside "coredll.dll".
Hope this gives you a good start :)
|
|
|
Carlos Martinez
ABB |
|
![]() |
|
pawl
Newbie
Joined: 2010-January-15 Location: Czech Online Status: Offline Posts: 3 |
Quote Reply
Posted: 2010-June-27 at 11:23 |
|
I know, I thought my own DLL. Where I'll copy into? Because I don't have access to system directory.
|
|
![]() |
|
Niklas Skoglund
Moderator Group
Joined: 2007-December-12 Location: Sweden Online Status: Offline Posts: 111 |
Quote Reply
Posted: 2010-June-27 at 23:01 |
|
Hi,
here are some hints based on my experience from .NET.
I have not tried this on Compact Framework though.
You can dynamically load an unmanaged DLL using Win32 GetProcAddress, which you can call using P/Invoke.
Then you can call a function in this DLL using some interop-magic.
I have never tried to use P/Invoke directly to call methods in my own DLL's.
Probably it is possible but I'm not sure how the DllImport attribute searches for the DLL file, which is basically what you are asking;)
Here is a code snippet found on http://www.c-sharpcorner.com/UploadFile/PatrickSmacchia/CSharp2UnsafeCode02162006063859AM/CSharp2UnsafeCode.aspx.
using System;
using System.Runtime.InteropServices; class Program { internal delegate bool DelegBeep(uint iFreq, uint iDuration); [DllImport("kernel32.dll")] internal static extern IntPtr LoadLibrary(String dllname); [DllImport("kernel32.dll")] internal static extern IntPtr GetProcAddress(IntPtr hModule,String procName); static void Main() { IntPtr kernel32 = LoadLibrary( "Kernel32.dll" ); IntPtr procBeep = GetProcAddress( kernel32, "Beep" ); DelegBeep delegBeep = Marshal.GetDelegateForFunctionPointer(procBeep , typeof( DelegBeep ) ) as DelegBeep; delegBeep(100,100); } } When you call LoadLibrary, you can specify the full path of your DLL.
|
|
|
Best Regards, Niklas Skoglund
ABB Robotics |
|
![]() |
|
Post Reply
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |