PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
importing dll-VBForums
Results 1 to 16 of 16

Thread: importing dll

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 1999
    Location
    New Jersey
    Posts
    334

    importing dll

    Hi all,
    Though there seem to be numerous posts on these forums about importing or exporting ActiveX dlls, but I am having troubles with just a standard dll. I have just created a simple test dll in C, as follows:
    Code:
    __declspec(dllexport) int UpdateAI(void)
    {
    
    	return 42;
    	
    }
    I compiled this into a dll, then tried importing it into my VB app as follows:
    VB Code:
    1. Declare Function UpdateAI Lib "c:\mydirectory\mydll.dll" () as Integer
    But when I try to access the function, I get the following error message:
    Run-time error '453':
    Can't find DLL entry point UpdateAI in "c:\mydirectory\mydll.dll"
    This is my first time working with DLLs, and so I don't really know much about what I'm doing. Any help would be appreciated! Thanks.
    Last edited by spandex44; Jan 28th, 2005 at 06:12 PM.

  2. #2
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,698

    Re: importing dll

    Declare Function UpdateAI Lib "c:\mydirectory\mydll.dlll" () as Integer
    did you mean to use mydll.dLL instead of mydll.dLLL?
    kevin
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 1999
    Location
    New Jersey
    Posts
    334

    Re: importing dll

    Thanks, but that wasn't the problem, I just rewrote the code for this post and made a typo.

    Any other help appreciated!

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 1999
    Location
    New Jersey
    Posts
    334

    Re: importing dll

    Bump.

    Anyone else?

  5. #5
    Lively Member vbgamer45's Avatar
    Join Date
    Sep 2004
    Posts
    67

    Re: importing dll

    It looks like you have to make a DEF file listing the function names you wish to export. Since they have the same problem you have with the entry point

    For more information read this article http://www.codeproject.com/dll/XDllPt2.asp

    Another way you can load a dll and not even declare it is using the LoadLibrary function
    Semi VB Decompiler 0.07 Getting better everyday
    http://www.visualbasiczone.com/produ...ivbdecompiler/
    VisualBasicZone
    http://www.visualbasiczone.com
    EasyPHPBB.com
    Free PHPBB forums the quick and easy way!

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 1999
    Location
    New Jersey
    Posts
    334

    Re: importing dll

    Thanks for the help, good link too!

  7. #7
    New Member
    Join Date
    Feb 2005
    Posts
    4

    Re: importing dll

    No expert in c or c++ but in c++ i think you need to use stdcall and add an extern "c" to avoid name mangling. You can also export you export through a def file or by declaing them in a header.

    something like,

    VB Code:
    1. extern "C" __declspec( dllexport ) __stdcall int Helloworld()
    2. {
    3.     return 1;
    4. };

    for the cpp file, and then declare this as an export in the h file. Havent done this for a while.

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 1999
    Location
    New Jersey
    Posts
    334

    Re: importing dll

    Ahh, still nothing is working. I have attached a zip file containing the dll, the .lib file, and the C source code. I wouild really apprecaite it if anyone could have a go and see how to make this work or determine what the problem is, I'm lost!
    Thanks in advance
    Attached Files Attached Files
    Last edited by spandex44; Feb 5th, 2005 at 09:47 AM.

  9. #9
    Lively Member vbgamer45's Avatar
    Join Date
    Sep 2004
    Posts
    67

    Re: importing dll

    Source is not included in the zip file. Right now there are no exports at all in the dll.
    Semi VB Decompiler 0.07 Getting better everyday
    http://www.visualbasiczone.com/produ...ivbdecompiler/
    VisualBasicZone
    http://www.visualbasiczone.com
    EasyPHPBB.com
    Free PHPBB forums the quick and easy way!

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 1999
    Location
    New Jersey
    Posts
    334

    Re: importing dll

    Oops, sorry, uploaded the wrong one! Here's the correct one.
    Thanks for taking a look.

    BTW: I tried adding a .def file, but to no effect. Running dumplib /exports shows me that the function name is fine (undistorted).
    Attached Files Attached Files

  11. #11
    Lively Member vbgamer45's Avatar
    Join Date
    Sep 2004
    Posts
    67

    Re: importing dll

    The dll works fine.
    To call it just do
    Private Declare Function UpdateAI Lib "VBGame.dll" () As Long
    Semi VB Decompiler 0.07 Getting better everyday
    http://www.visualbasiczone.com/produ...ivbdecompiler/
    VisualBasicZone
    http://www.visualbasiczone.com
    EasyPHPBB.com
    Free PHPBB forums the quick and easy way!

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 1999
    Location
    New Jersey
    Posts
    334

    Re: importing dll

    Did you try calling the UpdateAI function?

    I still get the error message: "Can't find entry point UpdateAI in VBGame.dll"

    Here's all of my code:
    VB Code:
    1. Private Declare Function UpdateAI Lib "VBGame.dll" () As Long
    2.  
    3. Private Sub Command1_Click()
    4.     Dim myLong As Long
    5.     myLong = UpdateAI
    6.     MsgBox Str(myLong)
    7. End Sub

    Does this code work for you?

  13. #13
    Lively Member vbgamer45's Avatar
    Join Date
    Sep 2004
    Posts
    67

    Re: importing dll

    Yes you may want to include the dll in the system32 folder or put in the folder of your application.
    Semi VB Decompiler 0.07 Getting better everyday
    http://www.visualbasiczone.com/produ...ivbdecompiler/
    VisualBasicZone
    http://www.visualbasiczone.com
    EasyPHPBB.com
    Free PHPBB forums the quick and easy way!

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 1999
    Location
    New Jersey
    Posts
    334

    Re: importing dll

    Well, I put it in my system32 folder and it worked fine, as well as when I put it in the folder of my application. Thanks a lot!

    However, it doesn't want to work when it is in a ompletely different directory, any idea why this is?

    Thanks for your help thus far.
    Last edited by spandex44; Feb 5th, 2005 at 01:52 PM.

  15. #15
    New Member
    Join Date
    Jun 2005
    Posts
    2

    Re: importing dll

    hi all ;

    i try to make dll file by vb.net ,(( i'm not work with C programming ))
    and i need to make dll file and call it , but it not work
    I get the error message: "Can't find entry point ........ "

    can we do this example in VB.NET ( make dll file by vb.net )

  16. #16
    New Member
    Join Date
    Jun 2005
    Posts
    2

    Re: importing dll

    anyone know this ??

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width