RobotStudio event

DLLImport - unmanaged modul

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

Comments

  • 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
  • I know, I thought my own DLL. Where I'll copy into? Because I don't have access to system directory.   

  • 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

    Developer Center
    RobotStudio Blog