views:

96

answers:

4

Hello,

nowadays I have this piece of code:

#import "C:\Users\Public\SoundLog\DLLs\ForPython\SoundLogDLL.tlb" named_guids

but I want to substitute the C:\Users\Public part by the %PUBLIC% environment variable.

How can I do this ?

+1  A: 

Not sure you can do that. You may either generate the file during a pre compile build step, or you can use the angle include #import <filename> <attrs> and have the location of it in your PATH. See MSDN for more info, specifically Search Order for filename.

SB
+1  A: 

Using a hard coded path in your code is never a good idea.
I recommend using a relative path and keeping your type library under the same folder structure as your code.

Then doing something like this:
#import <SoundLogDLL.tlb> named_guids

Zamboni
A: 

It would be wise to store your projects in a common folder so that you can use relative paths. The #import directive also searches files in the same folders where it looks for #include files. In the IDE, you can add them with Project + Properties, C/C++, General, Additional Include Directories.

Hans Passant
I have a lot of projects that work toogether. So, my common folder is that one that I specified in the question :D
aF
@aF: you are getting a lot of unhelpful answers here. Are you sure SO is the right place for you?
Hans Passant
those answers allways help me to find the real one :)
aF
+1  A: 

I think that your best option is to write #import "SoundLogDLL.tlb" named_guids in your code, and then use either the INCLUDE environment variable, the /I command-line switch to the compiler, or the Additional Include Directories IDE option to point the compiler in the right direction.

Aaron Klotz