CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2000
    Posts
    14

    passing an int val from C dll to Vb

    Hi ,

    currently , i am facing the problem of pass an int value from C Dll to a VB program.
    my problem is ==>
    when i pass an int value from C dll to vb , i am getting always zero val of that int in my Vb appln.

    In Vb i have declared as :-

    public declare funtion abc lib "c:\winnt\system32\mydll.dll" (byval myint as long) as integer

    while in my Vb program i am calling this function as

    return= abc(myint)

    can you tell me what might be the problem ...
    thanks


  2. #2
    Join Date
    May 2000
    Posts
    35

    Re: passing an int val from C dll to Vb

    In your VB declare for the function abc, declare it 'as long' instead of 'as int'.


  3. #3
    Join Date
    Jun 2000
    Posts
    8

    Re: passing an int val from C dll to Vb

    how did you get the dll to work with your vb app. i have a win32 dll and i cannot get it to work with vb. it always say that it could not find the entry point into the dll.


  4. #4
    Guest

    Re: passing an int val from C dll to Vb

    HI

    make a file => mydllname.def
    in that declare all your procedure names like this =>
    EXPORTS proc_name @1 PRIVATE

    In your mydllname.C file do this =>

    int _stdcall proc_name()
    {
    }

    this is working for me .. just try this .i think it will solve your problem.



  5. #5
    Join Date
    Jun 2000
    Posts
    8

    Re: passing an int val from C dll to Vb

    It cannot find the entry point because C++ is mangling the names in the DLL and you are declaring the functions by there regular names in VB. you can do 1 of 2 things. in your DLL code declare your functions with extern "C". This will cause you to remove the prototype definitions. or you can access the functions by ordinal number. the ordinals can be found by using the dumpbin utility that comes with VC. use the /EXPORTS parameter and give it the full path to your DLL. then in VB specify Alias "#n" where n is the ordinal number.


  6. #6
    Join Date
    Jun 2000
    Posts
    8

    Re: passing an int val from C dll to Vb

    Make sure your not mixing data types. A long in VB is the same as an INT in C++ and an INTEGER in VB is the same as a SHORT in C++


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured