Trying to call an ActiveX DLL from Delphi...

Hi, I have an ActiveX DLL from a software security package I purchased about 9 years ago (company now defunct), which I'd like to call from a Delphi program. The DLL is written in C or VB I think. The docs that came with it show how to call it from a VB project, but that doesn't help me much for Delphi. Here's what the docs say:

----------------------------------------------

(1) From the Project menu, choose References as shown in Figure 1.1.
(2) The References dialog box is displayed, as shown in Figure 1.2. Look for CodeLockKeyGen. If you can't find it, click on the "Browse..." button and look for the Code-Lock Keygen.DLL in the directory where you installed Code-Lock. Select the check box to the left of the CodeLockKeyGen.
(3) Choose OK to close the References dialog box. After adding the reference, you can make use of the ActiveX DLL as below.

First, you will need to declare it like below:

Private KG As New CodeLockKeyGen.KeyGen


The only function in the ActiveX DLL is .Get_RegistrationCode. To make use of it, you need to supply it with the necessary variables.

The format for the function is as below:

.Get_RegistrationCode("Program Code", "User Data", "Name of User", "Filename", ProtFlag)

Rules:

1) The variables must be in the specified sequence.
2) If you do not supply the Filename variable, the Registration Code will be returned from the function. If you supply a filename for the variable, a text file containing the Registration Code will be produced in the directory of the ActiveX DLL.
3) If you supply the Filename variable, the return value will always be "True". However, if there is any error during the generation of the Registration Code, the text file as specified will not be produced. An error log file named "Error.log" will be produced instead.
4) If you do not specify the Filename variable, the return value will be the Registration Code unless there is any error during the generation of the Registration Code, in which case, the return value will be "Error". An error log file named "Error.log" will also be produced.

Example:

Dim strResult As String
strResult = KG.Get_RegistrationCode("12345678", "ED3E78BDB99C15A36DB6746B9966B6ECCFF62E8202EEB9956DC83B7F15C4AF00", "ChosenBytes", "RegFile - ChosenBytes.txt", True)
While Len(strResult) = 0 ' to wait for the Registration Code generation
DoEvents
Wend
MsgBox strResult   ' strResult will contain the Registration Code


The above example will input the following values:

Program Code: "12345678"
User Data: "ED3E78BDB99C15A36DB6746B9966B6ECCFF62E8202EEB9956DC83B7F15C4AF00"
Name of User: "ChosenBytes"
Filename: "RegFile - ChosenBytes.txt"
ProtFlag: True

This will produce a text file with the name of "RegFile - ChosenBytes.txt" containing the Registration Code.

----------------------------------------------

I tried making a barebones Delphi project to attempt to call this using what little experience I have in calling DLL's, but kept getting :

---------------------------
TestDLL.exe - Entry Point Not Found
---------------------------
The procedure entry point Get_RegistrationCode could not be located in the dynamic link library Code-Lock Keygen.DLL.
---------------------------
OK  
---------------------------


Would anyone be able to shed any light on this please? I can send you the DLL to your private mailbox if you wish - I don't want to attach it here and make it publicly available.

Thanks!
   Shawn
shawn857Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jimyXCommented:
Did you import it as ActiveX Control?

Please send it over.
"My profile name" @live.com
0
shawn857Author Commented:
Hi Jimy... okay, coming your way. No I didn't import it in... wasn't really sure what to do there. It's not an ActiveX "package", it's just a dll file.

Thanks
    Shawn
0
jimyXCommented:
That DLL has four functions, non of them is "Get_RegistrationCode":
DllCanUnloadNow
DllGetClassObject
DllRegisterServer
DllUnregisterServer

Either that was the wrong DLL or there are extra missing steps.
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

shawn857Author Commented:
That's strange Jimy, I had ran a utility called "ActiveXplorer" on it a while back (and just did so again), and it does show that function in there. See attached screenshot please.

Thanks
   Shawn
ActiveXplorer.PNG
0
jimyXCommented:
OK, I figured it out.

Which Delphi version you are using?
0
shawn857Author Commented:
Delphi 7
0
jimyXCommented:
You need to Import a Type Library.
In Delphi XE:
From the menu -> Components -> Import Component... -> Import a Type Library and then locate that DLL, Add it if not listed, Next, select Palette Page, Next, Install to a new package, add a name and Finish.

Now start a new project, go to the Palette page where that Type Library were installed in, and drop KeyGen component and the rest, is similar to the documentation, is calling "KeyGen1.Get_RegistrationCode(...)".
0
jimyXCommented:
Wrong assumption, sorry :)

In Delphi 7 (make sure to Run As Admin.):
From Delphi menu -> Component -> Import ActiveX Control... -> Locate the DLL or Add if not listed, Select Palette Page and Install.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
shawn857Author Commented:
OK, I put the DLL in one of my Search Paths, but when I go into Import ActiveX Control, it's still not listed in the window of all the ActiveX controls and DLL's. So I clicked ADD and tried to add it in. It was looking for only .ocx files, but I changed it to "All Files", found the DLL file and added it. The window showing the list of controls and DLLs "flashed" so I thought it may have worked, but it did not add it to the list  :-(

I though when you imported an ActiveX, it was supposed to be an ocx? This is only a DLL file. I know so little about this stuff.....

Thanks
    Shawn
0
shawn857Author Commented:
Is this going to be a component that can be "dropped" on a form? I assumed it was just a DLL that got called straight from my app?

Shawn
0
jimyXCommented:
> Is this going to be a component that can be "dropped" on a form?
Yes.

I assumed it was just a DLL that got called straight from my app?
The DLL can be anything.

Do you have a team viewer?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.