Link to home
Start Free TrialLog in
Avatar of Netikus
NetikusFlag for United States of America

asked on

Accessing a class from DLL

Hello,

I'm not an experienced VB developer, I focus mainly on C/C++ and would need assistance. I have been given some sample code that I need to integrate in a project:

Dim DMApp   As New SomeClass.Application
Dim Lib     As SomeClass.Library
Dim Prof    As SomeClass.Profile

Then, I was informed that I would need to "reference" the

* fsplugin.dll
* pcdclient.dll

DLLs. Now, how do I reference these DLLs, and how do I access the classes and tell VB that it needs to look for the SomeClass class in the DLLs?

I ran across something like this:

Dim oVBObject As Object
Dim DummyVar as Variant

Set oVBObject = CreateObject("DLLName.ClassName")

and am wondering whether I can do that, just like

Dim oVBObject As Object
Set oVBObject = CreateObject("fsplugin.SomeClass")

and then do

Dim DMApp   As New oVBObject.Application
Dim Lib     As oVBObject.Library
Dim Prof    As oVBObject.Profile

Am I completely off track? Did those guys give me enough information? I feel like I'm missing something - like how do I know which DLL I really need, and how do I declare it etc.?

Thanks for any hints!


Flo.
Avatar of nffvrxqgrcfqvvc
nffvrxqgrcfqvvc

This all depends if your DLL is an activeX DLL or a standard windows DLL?
Avatar of Netikus

ASKER

Well, I haven't been told what it is, but I am 99% sure that it's a standard windows DLL. They don't do any other ActiveX stuff - so let's say safely assume it's a standard Windows DLL.

Does that help?
ASKER CERTIFIED SOLUTION
Avatar of justchat_1
justchat_1

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
O one thing missing from your code:
for all three you need to set the variable (form load is a good spot but can be in subs or functions)

ex:
Dim DMApp   As SomeClass.Application

should have a matching:
set DMApp = new SomeClass.Application

Hope that helps...
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
To  make one thing clear here, If its a standard windows DLL than you should see exported functions in the DLL. If this is the case you can call these functions using (Private Declare Function ExportName lib "Libraryname.dll" (parameters, etc..). However without knowing the parameters for the function your not going to make any progress.
Avatar of Netikus

ASKER

One thing that I'm confused about is how to handle classes.

I think I know how to reference a function in a DLL, e.g.

Private Declare Function MySpecialFunction Lib "mydll.dll" (ByVal FirstParm As Long, ByVal SecondParm As Long)

but how does this help - or how do I declare this - when I am referencing objects?

Dim DMApp   As New SomeClass.Application
Dim Lib     As SomeClass.Library
Dim Prof    As SomeClass.Profile

I followed justchat's advise and when to Project -> References and added both the DLLs in there. However, when I compile my project I get the following error:

"Compile error" "User-defined type not defined"

Here is the code so far:

0:Dim DocsObject As Object
1:Set DocsObject = CreateObject("FsPlugin.DOCSObjects")
2:Dim DMApp As DocsObject.Application

The error appears in line 2. I'm currently waiting for the documentation on this software but having the DLLs (fsplugin.dll and pcdclient.dll) I feel that I should get it to work?


Thanks!
Avatar of Netikus

ASKER

I was able to add the DLLs that I was given as references and that actually did the trick. I was then able to solve the problem, turns out the sample code that I was given wasn't exactly good and I had to tweak it.

There was never any DOCSObjects object in there, it was just an "Application", "Library" and "Profile" object. Just referencing those by itself worked like a charm.

Thanks again.