13 Replies - 583 Views - Last Post: 07 May 2012 - 01:12 PM Rate Topic: -----

#1 Neku  Icon User is offline

  • D.I.C Regular

Reputation: 18
  • View blog
  • Posts: 258
  • Joined: 21-May 09

question about reference

Posted 03 May 2012 - 10:02 AM

so.. it bugs me for a while.. when i add reference to a DLL file for example that is located in different place than my program's folder, does it mean that on any computer the file will have to be installed on that specific path?
aka a reference to a file located on C:\some folder\some file.dll will need any computer to have that folder? or can i later put the file in my program's folder and be sure that it would work fine?

thanks ahead for answers :)

Is This A Good Question/Topic? 0
  • +

Replies To: question about reference

#2 maj3091  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 274
  • View blog
  • Posts: 1,653
  • Joined: 26-March 09

Re: question about reference

Posted 03 May 2012 - 10:14 AM

Providing that the files are registered on the system, it should work.

When developing, I would write and compile my DLL's in a COMPILED folder for the DLL project, then reference the DLL from that location in the EXE file that will use it, but when deploying to a customer machine, the DLL's will be installed in the Windows System folder and registered there and the application runs quite happily.

I'm sure Bob will give you a far more technical explanation as to how it all works. :)
Was This Post Helpful? 1
  • +
  • -

#3 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 562
  • View blog
  • Posts: 2,935
  • Joined: 19-May 09

Re: question about reference

Posted 03 May 2012 - 01:12 PM

If you register your DLL (which is automatic if you compile it, but you can also use regsvr32.exe to do it manually), the registry will contain the following values:
1. in HKEY_CLASSES_ROOT, a folder with a name in the form YourProjectName.YourClassName, one for each class in your project. This is called the ProgId.
2. Inside the ProgId folder, there will be a CLSID key. This will have a GUID value. (This "Globally Unique Identifier" is the universal ID for your class no matter where it is installed.)
3. HKEY_CLASSES_ROOT has a subfolder called CLSID. CLSID has subfolders whose titles are the GUID values referenced by the ProgIds I mentioned in 1. (CLSID is a very large subfolder.)
4. Each of these CLSID folders contains various keys. One of the keys for a DLL is InProcServer32. The value of this key is the pathname of your dll.

You may want to track down this pathname yourself for your DLL as this structure will become clear to you if you do.

Interestingly, this is part of why early binding is quicker than late binding. Late binding compiles the ProgId, and uses it to look up the CLSID and from there the location of the library. Early binding does this lookup at compile time and compiles the CLSID directly.

This post has been edited by BobRodes: 03 May 2012 - 01:21 PM

Was This Post Helpful? 1
  • +
  • -

#4 Neku  Icon User is offline

  • D.I.C Regular

Reputation: 18
  • View blog
  • Posts: 258
  • Joined: 21-May 09

Re: question about reference

Posted 03 May 2012 - 02:56 PM

early binding is when i make reference or when i write code similar to this?


Public Declare Function AccessCheck Lib "advapi32.dll" Alias "AccessCheck" (pSecurityDescriptor As SECURITY_DESCRIPTOR, ByVal ClientToken As Long, ByVal DesiredAccess As Long, GenericMapping As GENERIC_MAPPING, PrivilegeSet As PRIVILEGE_SET, PrivilegeSetLength As Long, GrantedAccess As Long, ByVal Status As Long) As Long



how do i look up in the registry?
in the end i'd like that a file i have reference for will be in the folder of the program that use it (however placing it in windows\system32 seems good)

also if i now register the file to windows\system32 what effect will it have on my program?
will it use the dll from windows\system32 or will it use the original path where the dll was compiled?

This post has been edited by Neku: 03 May 2012 - 02:59 PM

Was This Post Helpful? 0
  • +
  • -

#5 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 562
  • View blog
  • Posts: 2,935
  • Joined: 19-May 09

Re: question about reference

Posted 05 May 2012 - 09:15 AM

This is an example of a "classic DLL", and the information I've given doesn't apply. It applies to COM DLLs. Rather than go into the difference in detail just now, you might like to first have a look at my tutorial on COM DLLs here. Let me know if you have further questions.
Was This Post Helpful? 0
  • +
  • -

#6 Neku  Icon User is offline

  • D.I.C Regular

Reputation: 18
  • View blog
  • Posts: 258
  • Joined: 21-May 09

Re: question about reference

Posted 05 May 2012 - 10:35 AM

well the program i use to deploy update files if and when needed.
so whenever i compile new version to my program i put reference to the dll but when i install i put it on C:\windows\system32
Was This Post Helpful? 0
  • +
  • -

#7 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 562
  • View blog
  • Posts: 2,935
  • Joined: 19-May 09

Re: question about reference

Posted 05 May 2012 - 04:17 PM

Early binding vs late:
Dim myObject as myClass
Set myObject = New myClass 'early
Dim myObject as Object
Set myObject New myClass 'late
The declare statement has nothing to do with either.

How do you look up in Registry? First, run regedit.exe. Go to HKEY_CLASSES_ROOT. Find your class. Look up the CLSID. Go to the CLSID directory. Find the CLSID in there, open up the folder. Look in the folder InProcServer32. You'll see the path to where your DLL is.

This post has been edited by BobRodes: 05 May 2012 - 04:19 PM

Was This Post Helpful? 1
  • +
  • -

#8 Neku  Icon User is offline

  • D.I.C Regular

Reputation: 18
  • View blog
  • Posts: 258
  • Joined: 21-May 09

Re: question about reference

Posted 06 May 2012 - 08:04 AM

i looked up in the registry but did not find InProcServer32 for my dll >.<
Was This Post Helpful? 0
  • +
  • -

#9 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 562
  • View blog
  • Posts: 2,935
  • Joined: 19-May 09

Re: question about reference

Posted 07 May 2012 - 06:33 AM

Did you write the DLL yourself? And, how do you access the DLL's methods? Do you use Declare or do you instantiate an object?

p. s. Do you really not have an hour to go through my tutorial? I did my best to make it informative and interesting, and to make it so you can skip parts that don't interest you. :)

This post has been edited by BobRodes: 07 May 2012 - 07:12 AM

Was This Post Helpful? 0
  • +
  • -

#10 Neku  Icon User is offline

  • D.I.C Regular

Reputation: 18
  • View blog
  • Posts: 258
  • Joined: 21-May 09

Re: question about reference

Posted 07 May 2012 - 07:53 AM

its a DLL i wrote by myself via BV6
its connected to a program via reference.

i declare it this way:

Dim PrintVar As New PrintTxt.StartPrint



and use it this way:

Call BootPrinterSettings 'used to get page settings for the printer from INI file


PrintVar.PrntTxt PrntLinesPerPage, Tpos, Lpos, Lwidth, Smode, TitleFS, TxtFS, LineOffset, Text1.Text, CD.Copies, TitleBuffer



what i hoped to do was to place the DLL inside the folder of the program that use it, but since i reference it i thought the program may not recognize the DLL on machines other than the PC on which i developed it.
it seems to work when i set the install app to deploy the file on C:\windows\system32

and about your tutorial, i want to read it but cant because i have lately too much work >.<
i'm responsible to check all parts for a machine we make at work.. and i'm alone on that part of the assembly line T_T

This post has been edited by Neku: 07 May 2012 - 07:55 AM

Was This Post Helpful? 0
  • +
  • -

#11 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 562
  • View blog
  • Posts: 2,935
  • Joined: 19-May 09

Re: question about reference

Posted 07 May 2012 - 11:04 AM

If you wrote it yourself in VB6, then it's registered. PrintText.StartPrint is a class, and you will find it in the HKEY_CLASSES_ROOT hive.

Your install app copies the DLL to the directory specified (I would use C:\Program Files\SomeFolderName rather than the system32 directory because that's standard practice) and then registers it. You will be able to see this for yourself if you follow the instructions I've given you.
Was This Post Helpful? 1
  • +
  • -

#12 Neku  Icon User is offline

  • D.I.C Regular

Reputation: 18
  • View blog
  • Posts: 258
  • Joined: 21-May 09

Re: question about reference

Posted 07 May 2012 - 11:59 AM

so if i get it right what matter is if the program i use to make install file register the DLL? and therefore it dosent matter that originaly the reference was to a folder different from where the app is installed?
will that appely even for the computer on which i develop the app?
Was This Post Helpful? 0
  • +
  • -

#13 Neku  Icon User is offline

  • D.I.C Regular

Reputation: 18
  • View blog
  • Posts: 258
  • Joined: 21-May 09

Re: question about reference

Posted 07 May 2012 - 12:08 PM

you are my hero :D

thanks you very much for solving my problem :D
Was This Post Helpful? 0
  • +
  • -

#14 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 562
  • View blog
  • Posts: 2,935
  • Joined: 19-May 09

Re: question about reference

Posted 07 May 2012 - 01:12 PM

View PostNeku, on 07 May 2012 - 01:59 PM, said:

so if i get it right what matter is if the program i use to make install file register the DLL? and therefore it dosent matter that originaly the reference was to a folder different from where the app is installed?
will that appely even for the computer on which i develop the app?
Correct. Correct. Yes. :)

You're welcome.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1