473,406 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How do I Retrieve Dir of my COM object?

I am building websites using Databases and COM for 3tier apps.

Currently I have to tell my COM object where the database is located either
1) Hardcoded in the DLL
2) Via my ASP call

How do I retrieve the dir where my DLL is located?
In the VB6 runtime environment "CurDir" does it for the runtime-situation
Once I go "DLL" CurDir is retrieving the current active dir, that could be
anything.

Is a solution present by Microsoft?

== This is Where I want to go to:
I want to create/call something inside the DLL like "thisDLLpath" (read: any
VB instruction doing just that)

When the DLL is located in "c:\myDLLs\testDLL", the call "thisDLLpath"
within the DLL should return just that.
When I move the DLL to "D:\myDLLs\finalLocation" (on another server), the
call "thisDLLpath" within the DLL should return just that

== Why?
When building websites using 3tier, currently I need to set the full path
(or the ODBC name) to the database in either:
1) my ASP script
2) the ODBC manager

Just using the DLL with thisDLLpath enables me to cut away extra settings
and place the DB anywhere. It is less rigid (copy & paste DLL and DB into a
Dir, register the DLL and presto!) Working on two or three different servers
it is the most flexible way to go.
Jul 17 '05 #1
4 4210
Global iret As Long
Global Filename As String
Global iret1 As Long
Global sValuename As String
Global lValuename As Long
Global pos As Long
Global lindex As Long
Global dwType As Long
Global lHandle As Long
Global lHandle1 As Long
Global lindex1 As Long
Global sValuename1 As String
Global lValuename1 As Long
Global sValuename2 As String
Global lValuename2 As Long
Global sValuename3 As String
Global lValuename3 As Long
Global Const HKEY_CLASSES_ROOT = &H80000000
Global Const HKEY_CURRENT_CONFIG = &H80000005
Global Const HKEY_CURRENT_USER = &H80000001
Global Const HKEY_DYN_DATA = &H80000006
Global Const HKEY_LOCAL_MACHINE = &H80000002
Global Const HKEY_PERFORMANCE_DATA = &H80000004
Global Const HKEY_USERS = &H80000003
Global Const REG_BINARY = 3 ' Free form binary
Global Const REG_DWORD_BIG_ENDIAN = 5 ' 32-bit number
Global Const REG_DWORD = 4 ' 32-bit number
Global Const REG_EXPAND_SZ = 2 ' Unicode nul terminated
string
Global Const REG_SZ = 1 ' Unicode nul terminated
string

Public Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type

Public Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA"
(ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Public Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias
"RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal
ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Public Declare Function RegQueryValue Lib "advapi32.dll" Alias
"RegQueryValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal
lpValue As String, lpcbValue As Long) As Long
Public Declare Function RegQueryValueEx Lib "advapi32.dll" Alias
"RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal
lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
' Note that if you declare the lpData parameter as String, you must pass it
By Value.
Public Declare Function RegSetValue Lib "advapi32.dll" Alias "RegSetValueA"
(ByVal hKey As Long, ByVal lpSubKey As String, ByVal dwType As Long, ByVal
lpData As String, ByVal cbData As Long) As Long
Public Declare Function RegSetValueEx Lib "advapi32.dll" Alias
"RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal
Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long)
As Long ' Note that if you declare the lpData parameter as String,
you must pass it By Value.
Public Declare Function RegDeleteValue Lib "advapi32.dll" Alias
"RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Public Declare Function RegDeleteKey Lib "advapi32.dll" Alias
"RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
Public Declare Function RegEnumKey Lib "advapi32.dll" Alias "RegEnumKeyA"
(ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, ByVal
cbName As Long) As Long
Public Declare Function RegEnumKeyEx Lib "advapi32.dll" Alias
"RegEnumKeyExA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As
String, lpcbName As Long, ByVal lpReserved As Long, ByVal lpClass As String,
lpcbClass As Long, lpftLastWriteTime As FILETIME) As Long
Public Declare Function RegEnumValue Lib "advapi32.dll" Alias
"RegEnumValueA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal
lpValueName As String, lpcbValueName As Long, ByVal lpReserved As Long,
lpType As Long, lpData As Byte, lpcbData As Long) As Long

First, find the clsid:

iret = RegOpenKey(HKEY_CLASSES_ROOT, Dllname.ClassName & "\CLSID", lHandle)
iret1 = RegQueryValueEx(lHandle, "", o&, 1, ByVal sValuename, lValuename)

Now, find the location:

Running Local:

iret = RegOpenKey(HKEY_CLASSES_ROOT, "CLSID\" & Left$(sValuename, 38) &
"\inprocserver32", lHandle)

DCOM server:

iret = RegOpenKey(HKEY_CLASSES_ROOT, "CLSID\" & Left$(sValuename, 38) &
"\_inprocserver32", lHandle)

sValuename1 = Space$(255)
lValuename1 = 255

iret1 = RegQueryValueEx(lHandle, "", o&, 1, ByVal sValuename1, lValuename1)

Pos = instr(sValuename1, Chr(0))

MyPath = Left$(sValuename1, pos-1)
"Peter Kaptein" <pe**********@hotmail.com> wrote in message
news:40*********************@news.xs4all.nl...
I am building websites using Databases and COM for 3tier apps.

Currently I have to tell my COM object where the database is located either 1) Hardcoded in the DLL
2) Via my ASP call

How do I retrieve the dir where my DLL is located?
In the VB6 runtime environment "CurDir" does it for the runtime-situation
Once I go "DLL" CurDir is retrieving the current active dir, that could be
anything.

Is a solution present by Microsoft?

== This is Where I want to go to:
I want to create/call something inside the DLL like "thisDLLpath" (read: any VB instruction doing just that)

When the DLL is located in "c:\myDLLs\testDLL", the call "thisDLLpath"
within the DLL should return just that.
When I move the DLL to "D:\myDLLs\finalLocation" (on another server), the
call "thisDLLpath" within the DLL should return just that

== Why?
When building websites using 3tier, currently I need to set the full path
(or the ODBC name) to the database in either:
1) my ASP script
2) the ODBC manager

Just using the DLL with thisDLLpath enables me to cut away extra settings
and place the DB anywhere. It is less rigid (copy & paste DLL and DB into a Dir, register the DLL and presto!) Working on two or three different servers it is the most flexible way to go.

Jul 17 '05 #2
"Richard T. Ed*****@pwpsquared.net" <re****@pwpsquared.net> wrote in message news:<O2**************@TK2MSFTNGP11.phx.gbl>...
Global iret As Long
Global Filename As String
Global iret1 As Long
Global sValuename As String
Global lValuename As Long
Global pos As Long
Global lindex As Long
Global dwType As Long
Global lHandle As Long
Global lHandle1 As Long
Global lindex1 As Long
Global sValuename1 As String
Global lValuename1 As Long
Global sValuename2 As String
Global lValuename2 As Long
Global sValuename3 As String
Global lValuename3 As Long
Global Const HKEY_CLASSES_ROOT = &H80000000
Global Const HKEY_CURRENT_CONFIG = &H80000005
Global Const HKEY_CURRENT_USER = &H80000001
Global Const HKEY_DYN_DATA = &H80000006
Global Const HKEY_LOCAL_MACHINE = &H80000002
Global Const HKEY_PERFORMANCE_DATA = &H80000004
Global Const HKEY_USERS = &H80000003
Global Const REG_BINARY = 3 ' Free form binary
Global Const REG_DWORD_BIG_ENDIAN = 5 ' 32-bit number
Global Const REG_DWORD = 4 ' 32-bit number
Global Const REG_EXPAND_SZ = 2 ' Unicode nul terminated
string
Global Const REG_SZ = 1 ' Unicode nul terminated
string


I think that's more global variables than in all the VB I've ever done combined.

Doesn't App.Path within the DLL return the path to the DLL?
Jul 17 '05 #3
app.path
"Peter Kaptein" <pe**********@hotmail.com> schreef in bericht
news:40*********************@news.xs4all.nl...
I am building websites using Databases and COM for 3tier apps.

Currently I have to tell my COM object where the database is located either 1) Hardcoded in the DLL
2) Via my ASP call

How do I retrieve the dir where my DLL is located?
In the VB6 runtime environment "CurDir" does it for the runtime-situation
Once I go "DLL" CurDir is retrieving the current active dir, that could be
anything.

Is a solution present by Microsoft?

== This is Where I want to go to:
I want to create/call something inside the DLL like "thisDLLpath" (read: any VB instruction doing just that)

When the DLL is located in "c:\myDLLs\testDLL", the call "thisDLLpath"
within the DLL should return just that.
When I move the DLL to "D:\myDLLs\finalLocation" (on another server), the
call "thisDLLpath" within the DLL should return just that

== Why?
When building websites using 3tier, currently I need to set the full path
(or the ODBC name) to the database in either:
1) my ASP script
2) the ODBC manager

Just using the DLL with thisDLLpath enables me to cut away extra settings
and place the DB anywhere. It is less rigid (copy & paste DLL and DB into a Dir, register the DLL and presto!) Working on two or three different servers it is the most flexible way to go.

Jul 17 '05 #4
Thanks for the feedback.

Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Koen Van Herck | last post by:
For debugging/logging purposes, I have a function def Log(msg): print '%s.%s: %s' % (cls, method, msg) I call this function from a class method, and I would like to retrieve the name of the...
2
by: SteveR | last post by:
I want to return an ArrayList from my web service. I can write this part and everything compiles but I can't get the web application that uses the web service to compile. I call the service...
9
by: Don | last post by:
Say I have a class like so: Public Class MyClass Public Prop1 as Integer Public Prop2 As Integer Public Prop3 As Integer End Class Is it possible to retrieve a list of the variables or...
5
by: ggk517 | last post by:
We are trying to develop an Engineering application using PHP, Javascript with Informix as the back-end. Is it possible to retrieve data using Javascript but by accessing the Database. Say...
0
by: r1 | last post by:
I am relatively inexperienced in using delegates and asynchronous methods. I read several articles, and then I developed my own code with a mission to improve the performance. Wow! I cannot...
13
by: kev | last post by:
Hi all, I have created a database for equipments. I have a form to register the equipment meaning filling in all the particulars (ID, serial, type, location etc). I have two buttons at the end...
1
by: ahujasatna | last post by:
Hi all!! i am working on C#, ASP.Net with Sql server2000 and i am facing a problem, my Question is: "How to insert and retrieve images to/from Sqlserver2000 Database" I created a table...
8
by: active | last post by:
Guess I'm looking for someone who likes to work difficult puzzles. I can't seem to ever retrieve a palette handle from the clipboard. Below is a simple test program that demonstrates the...
0
by: NETCODE | last post by:
I am developing an add-in. I need to retrieve the path of .msi file, located in under project properties, from the deployment project (setup). I was able retieve all project properties of all...
2
by: Cramer | last post by:
Using ASP.NET 3.5... As far as I know, any time we store a value in application or session state, it is stored as a humble 'object' type rather than it's "real" type. For example, if we want...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.