Forum Home Forum Home > RobotStudio > Developer Tools
  New Posts New Posts
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

DLLImport - unmanaged modul

 Post Reply Post Reply
Author
Message
  Topic Search Topic Search  Topic Options Topic Options
pawl View Drop Down
Newbie
Newbie
Avatar

Joined: 2010-January-15
Location: Czech
Online Status: Offline
Posts: 3
  Quote pawl Quote  Post ReplyReply Direct Link To This Post Topic: DLLImport - unmanaged modul
    Posted: 2010-February-04 at 14:18
I tried to load DLL system user32.dl and import function MessageBoxA - no problem run Tongue(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 ... )Cry( 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 ? Wink
Back to Top
carlosmtz2000 View Drop Down
Senior Member
Senior Member


Joined: 2008-July-10
Location: United States
Online Status: Offline
Posts: 194
  Quote carlosmtz2000 Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
pawl View Drop Down
Newbie
Newbie
Avatar

Joined: 2010-January-15
Location: Czech
Online Status: Offline
Posts: 3
  Quote pawl Quote  Post ReplyReply Direct Link To This Post 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.   
Back to Top
Niklas Skoglund View Drop Down
Moderator Group
Moderator Group


Joined: 2007-December-12
Location: Sweden
Online Status: Offline
Posts: 111
  Quote Niklas Skoglund Quote  Post ReplyReply Direct Link To This Post 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;)
 
 
 
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
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.53
Copyright ©2001-2008 Web Wiz