Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 313
  • Last Modified:

How to call a function present in a COM based DLL

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
reacharun
Asked:
reacharun
  • 2
1 Solution
 
mmurrellCommented:
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
 
reacharunAuthor Commented:
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
 
mmurrellCommented:
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
 
bcladdCommented:
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now