VB.Net, RAPI.Invoke, and Creating Function DLL

Last post 07-01-2008 8:29 by joseluisocleppo. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 06-02-2007 11:56

    VB.Net, RAPI.Invoke, and Creating Function DLL

    I have a DLL that I've created and installed on my Pocket PC. It has a single function that looks like this:

    ---------------------------------------------
    ' Installed as \Windows\MyFunction.dll
    Public Function MyFunction () as String
    Return "Hello World"
    End Function
    ---------------------------------------------


    I have a separate desktop project that basically looks like:
    ---------------------------------------------
    Public Sub Test ()
    Dim iBytes As Byte() = StrToByteArray("") ' Just empty for now
    Dim oBytes As Byte() = StrToByteArray("") ' Just empty for now
    Dim myRAPI as New RAPI
    myRAPI.Connect()
    myRAPI.Invoke("\Windows\MyFunction.dll", "MyFunction", iBytes, oBytes)
    myRAPI.Disconnect()
    End Sub

    Public Shared Function StrToByteArray(ByVal str As String) As Byte()
    Dim encoding As New System.Text.ASCIIEncoding()
    Return encoding.GetBytes(str)
    End Function 'StrToByteArray
    ---------------------------------------------

    Every time I run this, it says that the paramater "source" cannot be null. I searched around and someone said that this is because the Invoke function is calling an internal procedure that is returning a null, which probably just means that I'm not calling my function correctly. I looked around and it looks like I may need to create a certain signature for my "MyFunction" function for it to be able to be called correctly. But I cannot figure out quite how to do this (I think I ALMOST have it figured out based on CeRAPIInvoke's signature, but I can't find a way to implement the IRAPIStream type without C++).

    My question is: can anyone put up an example of a properly-created function / signature in VB.net that can be compiled to a DLL, and then invoked by RAPI's Invoke method?

    - Jonathan
  • 06-03-2007 2:00 In reply to

    Re: VB.Net, RAPI.Invoke, and Creating Function DLL

    Hi jhilgeman,

    the main problem is, that you can only invoke native dll functions with rapi.Invoke(...), which means functions from dlls created with C++.

    What you can do, is using rapi.CreateProcess(...). This funtion allows you to execute a native or managed application. You can even use commandline parameters with it. Maybe this will already help, you.

    Cheers, Peter
  • 07-01-2008 8:29 In reply to

    Re: VB.Net, RAPI.Invoke, and Creating Function DLL

    Hello,

    I understand your question, the problem we need to call the function SetSystemMemoryDivision since since Windows CE 4.2 device I may not run without security.

    As I do?
     
    Jose Luis
     
Page 1 of 1 (3 items)