Important alert: (current site time 7/16/2013 2:21:43 AM EDT)
 

winzip icon

Universal dll function caller, update

Email
Submitted on: 3/18/2008 8:26:15 AM
By: Paul Caton 
Level: Intermediate
User Rating: By 23 Users
Compatibility: VB 5.0, VB 6.0
Views: 16071
 
     Just an update responding to previous user requests. Added fastcall support, call by pointer and every return type I could think of: Byte, Integer, Long, 64bit, Single, Double and none. March 10: two asm optimizations and some comments fixed. March 17: LaVolpe's requests added.

 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
  3. Scan the source code with Minnow's Project Scanner

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 13 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

3/5/2008 10:02:15 PMavien

Nice coding. Thank's 4 share it.
(If this comment was disrespectful, please report it.)

 
3/8/2008 8:11:47 PMLaVolpe

Paul, I can vouch for the cDecl portion -- appears flawless. I have ran it against 2 zlib versions: 1) cDECL 2) stdCALL. Calling same functions on both caused no problems and that is great. Now I don't need to know in advance if zlib is either/or, and I don't need separate routines for one or the other, and I can also cut down some redundancy. Thank you & a fiver for the code.
(If this comment was disrespectful, please report it.)

 
3/8/2008 8:47:31 PMLaVolpe

If you update project, maybe consider including these 2 functions:
1. isValidDLL(dllName) to return whether DLL exists in dll path?
2. isValidMethod(dllName,procName) to return whether method exists in DLL? For example, zlib has 2 versions, 1 with compress method & one with compress2 which requires extra parameter. If compress2 exists, then coder needs to provide extra parameter.
The above would be handy add-ons vs coding their own.
(If this comment was disrespectful, please report it.)

 
3/19/2008 10:25:19 AMKoutheir ATT

I really like your tries. Even if this atricle is not useful for me these moments, it's very interesting as a programming experience.
Take care from the overhead it can add to execution time compared to simple "Declare" VB statements or famous ".TLB" references ("module" statement in MIDL language).
(If this comment was disrespectful, please report it.)

 
3/19/2008 8:07:59 PMJoe Jordan

Excellent work. I'd love to see this used as a VB frontend to sqlite *hint hint to anyone reading this* :)
(If this comment was disrespectful, please report it.)

 
6/19/2008 7:17:41 PMzaz

Man, I wish I could vote again for this submission. It's simply great!
I wanted stuff like ADO-like sqlite wrappers without the 'hassle' of adding other COM files to certain projects and it worked out really well.
Also stuff like sprintf is finally accessible in VB!
(If this comment was disrespectful, please report it.)

 
10/29/2008 9:36:13 AMTonyYang

Excellent work! I am now upgrading some code written( or copied...) years ago which now causes DEP protection error on some DEP-Enabled enrionment such as Win 2008 server(by default DEP is enabled for all program...); i hope this code will do great help. thanks again!
(If this comment was disrespectful, please report it.)

 
10/14/2009 1:13:10 PMJP

Very nice but how would I call a function that returned a string? Also I need to call functions that have multiple parameters and multiple call backs
example vb dclare of dll function.
Public Declare Function decodefile Lib "decode.dll" (ByVal decoder As Long, ByVal FileSpec As String, ByVal Write_callback As Long, ByVal data_callback As Long, ByVal Error_callback As Long, ByVal client As String) as string

Thanks
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.