?
Solved

How to call a function present in a COM based DLL

Posted on 2003-02-25
4
Medium Priority
?
312 Views
Last Modified: 2013-11-25
I want to use a COM component known as DigiSign. Following is an extract of the help file.

About DigiSign 2.0
DigiSign implements the most popular message digest and checksum algorithms: SHA-1, SHA-256, SHA-384, SHA-512, MD5, MD2, RIPEMD160, CRC32 and ADLER32.

DigiSign can be used with any COM compliant environment: Scripting languages (VBScript, JavaScript), Visual Basic (Versions 4 and up), VBA (Word, Excel, Access ...), VC++, BC++, Delphi, Power Builder.

The VB Example that is given is as follows:

'DigiSign 2.0 VBScript Sample
'Create Hash Object
Set H = CreateObject ("DigiSign.Hash")

'Calculate the MD5 Signature of a string
S = H.CalculateStringDigest("This is our test string", 4)

====================================================================================================================
MY QUESTION is how do we do the same in C++/VC++
====================================================================================================================

Please note:
1. GUID is not provided
2. No .h files are provided
3. The above code works properly in VB
0
Comment
Question by:reacharun
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Accepted Solution

by:
mmurrell earned 200 total points
ID: 8031430
I would recommend importing the file that contains the object.  Running a generic compile after importing should generate a tlh (?? i might be wrong) file which contains most of the prototypes etc.  I used

#import "C:\Program Files\Donia Software\Digisign 2.0\Digisign.dll"

void main(void)
{

}

and a TLH file was generated in the debug directory when i compiled this. From that I was able to derive the class names, the members and the methods.  

#import "C:\Program Files\Donia Software\Digisign 2.0\Digisign.dll" no_namespace

void main(void)
{
     IHashPtr test;
     test.CreateInstance("DigiSign.Hash");

     test->About();
}

Hope this helps.
0
 

Author Comment

by:reacharun
ID: 8040258
Following is the dump of errors I got after doing what you specified

--------------------Configuration: testDigi - Win32 Debug--------------------
Compiling...
testDigi.cpp
E:\workarea\msdev\testDigi\testDigi.cpp(7) : error C2065: 'IHashPtr' : undeclared identifier
E:\workarea\msdev\testDigi\testDigi.cpp(7) : error C2146: syntax error : missing ';' before identifier 'test'
E:\workarea\msdev\testDigi\testDigi.cpp(7) : error C2065: 'test' : undeclared identifier
E:\workarea\msdev\testDigi\testDigi.cpp(8) : error C2228: left of '.CreateInstance' must have class/struct/union type
E:\workarea\msdev\testDigi\testDigi.cpp(10) : error C2227: left of '->About' must point to class/struct/union
Error executing cl.exe.

testDigi.obj - 5 error(s), 0 warning(s)
0
 

Expert Comment

by:mmurrell
ID: 8042031
Is the precompiler #import directive pointing to the correct location of the digisign DLL? I used the default installation directory.  Also, check the TLH file and ensure that the IHash object exists. Hope this will help.
0
 
LVL 11

Expert Comment

by:bcladd
ID: 9845977
No comment has been added lately, so it's time to clean up this TA. I will
leave a recommendation in the Cleanup topic area that this question is:

Answered: Points to mmurrell: Grade A

Please leave any comments here within the next seven days.

Experts: Silence means you don't care. Grading recommendations are made in light
of the posted grading guidlines (http://www.experts-exchange.com/help.jsp#hi73).

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

-bcl (bcladd)
EE Cleanup Volunteer
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

766 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question