Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using Environment Variables in VB6 Project files (.VBP)

845 views
Skip to first unread message

Dan

unread,
Aug 18, 2009, 9:55:47 AM8/18/09
to
Our company uses Visual Basic 6 for some legacy applications. For a
long time, we have suffered with several hardcoded paths in the VB6
project files ( .VBP) under the Reference Section.

I would like to change these references so that they use an
environment variable. I assumed I could use the syntax of Visual
Studio .net along the following lines:

Reference = ($MyEnvironmentVar)MyDll.dll

where MyEnvironmentVar is a path such as C:\MyDllDir\

But I can not get this reference to work. Is there some other way to
work with enviroment variables in the VB6 project file? Is there any
way to work with environment variables in VB6 projects?

Thanks,

Dan

Jan Hyde

unread,
Aug 18, 2009, 11:25:16 AM8/18/09
to
Dan <d...@6noels.com>'s wild thoughts were released on Tue,
18 Aug 2009 06:55:47 -0700 (PDT) bearing the following
fruit:

e.g.

Environ("APPDATA")


--
Jan Hyde

Auric__

unread,
Aug 18, 2009, 11:43:38 AM8/18/09
to

Short version: No.

Long version: Not without writing something to handle the .vbp file as (for
example) a makefile template.

If you have multiple developers working on the project, how about putting the
DLLs (or whatever) on a network share, and have everyone map it to the same
drive letter?

--
I support drug tests. Test the politicians.

Dan

unread,
Aug 21, 2009, 1:42:17 PM8/21/09
to
On Aug 18, 10:43 am, "Auric__" <not.my.r...@email.address> wrote:
> On Tue, 18 Aug 2009 13:55:47 GMT, Dan wrote:
> > Our company usesVisualBasic6 for some legacy applications. For a

> > long time, we have suffered with several hardcoded paths in the VB6
> >projectfiles( .VBP) under the Reference Section.

>
> > I would like to change these references so that they use an
> > environment variable. I assumed I could use the syntax ofVisual
> > Studio .net along the following lines:
>
> > Reference = ($MyEnvironmentVar)MyDll.dll
>
> > where MyEnvironmentVar is a path such as C:\MyDllDir\
>
> > But I can not get this reference to work. Is there some other way to
> > work with enviroment variables in the VB6projectfile? Is there any

> > way to work with environment variables in VB6 projects?
>
> Short version: No.
>
> Long version: Not without writing something to handle the .vbpfile as (for
> example) a makefile template.
>
> If you have multiple developers working on theproject, how about putting the

> DLLs (or whatever) on a network share, and have everyone map it to the same
> drive letter?
>
> --
> I support drug tests. Test the politicians.- Hide quoted text -
>
> - Show quoted text -

Thanks for the responses. I guess it is not possible to use
environment variables in the .vbp and VB6 without some type of macro-
replacement.

The network share approach won't work for us, because most developers
needs a stable set of libraries on which to build. We could run into
issues updating the network share. Also, we have a global development
team with many distributed developers (working from home and other
diverse places) so we need to be able to build off of local hard
drives.

Dan


Auric__

unread,
Aug 21, 2009, 2:34:37 PM8/21/09
to
On Fri, 21 Aug 2009 17:42:17 GMT, Dan wrote:

> On Aug 18, 10:43�am, "Auric__" <not.my.r...@email.address> wrote:
>> On Tue, 18 Aug 2009 13:55:47 GMT, Dan wrote:
>> > Our company usesVisualBasic6 for some legacy applications. For a
>> > long time, we have suffered with several hardcoded paths in the VB6
>> >projectfiles( .VBP) under the Reference Section.
>>
>> > I would like to change these references so that they use an
>> > environment variable. I assumed I could use the syntax ofVisual
>> > Studio .net along the following lines:
>>
>> > Reference = ($MyEnvironmentVar)MyDll.dll
>>
>> > where MyEnvironmentVar is a path such as C:\MyDllDir\
>>
>> > But I can not get this reference to work. Is there some other way to
>> > work with enviroment variables in the VB6projectfile? Is there any
>> > way to work with environment variables in VB6 projects?
>>
>> Short version: No.
>>
>> Long version: Not without writing something to handle the .vbpfile as
>> (for example) a makefile template.
>>
>> If you have multiple developers working on theproject, how about
>> putting the DLLs (or whatever) on a network share, and have everyone
>> map it to the same drive letter?
>

> Thanks for the responses. I guess it is not possible to use
> environment variables in the .vbp and VB6 without some type of macro-
> replacement.
>
> The network share approach won't work for us, because most developers
> needs a stable set of libraries on which to build. We could run into
> issues updating the network share. Also, we have a global development
> team with many distributed developers (working from home and other
> diverse places) so we need to be able to build off of local hard
> drives.

You could have them use LoadLibrary in the actual code. It would work
something like this (untested pseudo-code):
x$ = Environ$("MyEnvironmentVar")
if (Right$(x$, 1) <> "\" then x$ = x$ & "\"
l$ = x$ & "MyDll.dll"
if len(dir(l$)) then
hWnd& = LoadLibrary(l$)
if hWnd& then
p& = GetProcAddress(hWnd&, "FunctionNameGoesHere")
if p& then
CallWindowProc p&, param1, param2, .....
else
error 5 'Invalid procedure call
end if
FreeLibrary hWnd&
else
error 48 'Error in loading code resource or DLL
end if
else
msgbox "can't find MyDll.dll"
end if

Alternately, if you're primarily a .Net group, why not port the app to
VB.Net?

--
You're behind on your scientific literature.

0 new messages