I have tried this using CAPICOM dll and it woks well.
I have a custom DLL which has got the functions which can be used for digital signature creation/verification.
To Load the functions from my custom DLL i need to use functions from kernel32.dll .The funcions are SetErrorMode and LoadLibrary.
The functions i want to use are someting like
OriginalErrorValue = SetErrorMode(SEM_NOOPENFILEERRORBOX Or SEM_FAILCRITICALERRORS)
hInst = LoadLibrary("occlient.dll")
OriginalErrorValue = SetErrorMode(OriginalErrorValue)