[C++] Dll + Visual basic ( URGENT )

Results 1 to 7 of 7
  1. #1
    Sorcerer Supreme wolfulus is offline
    Member +Rank
    Jul 2006 Join Date
    BrazilLocation
    307Posts

    [C++] Dll + Visual basic ( URGENT )

    hey guys, i want to call a function from a dll writed in c++

    the c++ header of the function is:

    int __stdcall MyFunc(unsigned char*Arg1,unsigned char*Arg2,int Arg3);

    i added this to the top of visual basic code:

    Public Declare Function MyFunc Lib "MyFunctions.dll" (ByVal Arg1 As Long, ByVal Arg2 As Long, ByVal Arg3 As Long) As Long

    it still dont works

    obs: arg1 and arg2 is pointers and i'm calling it as
    return = MyFunc(VarPtr(bytearray(0), VarPtr(bytearray2(0)), mylongarg)
    what i should do for this ** work?


  2. #2
    Grand Master FragFrog is offline
    Grand MasterRank
    Aug 2004 Join Date
    The NetherlandsLocation
    5,629Posts
    Erm, to make that work you must suply the function with pointers, ie memory-adresses. If there isn't a pointer in VB, try the referenced value. Or use google ofcourse to search for pointers in VB

  3. #3
    Sorcerer Supreme wolfulus is offline
    Member +Rank
    Jul 2006 Join Date
    BrazilLocation
    307Posts
    VarPtr returns the pointer of some data man
    Unofficial Documentation for VarPtr, StrPtr, and ObjPtr

  4. #4
    Grand Master FragFrog is offline
    Grand MasterRank
    Aug 2004 Join Date
    The NetherlandsLocation
    5,629Posts
    Ah, silly me :icon6: Still, my knowladge of VB is minimal I'm affraid..

    Whats the error though? That'll probably shed some light into this situation.. :)

  5. #5
    Grand Master username1 is offline
    Grand MasterRank
    Jul 2004 Join Date
    5,867Posts
    I don't think the first two should be "ByVal". The other way of passing parameters (I forgot what it's called...)

  6. #6
    Sorcerer Supreme wolfulus is offline
    Member +Rank
    Jul 2006 Join Date
    BrazilLocation
    307Posts
    byref?

  7. #7
    Grand Master username1 is offline
    Grand MasterRank
    Jul 2004 Join Date
    5,867Posts
    Quote Originally Posted by wolfulus View Post
    byref?
    Yes. Ja. Oui.



Advertisement