tags:

views:

123

answers:

6

Hi

I have my visualstudio vcproj file at c:\vsproj\example\test\test.vcproj

under this path i have some other files like e test.cpp file and also a dll test.dll is there.

so totally under tha path c:\vsproj\example\test i have

1) test.vsproj 2) test.dll 3) test.cpp

normally to get the cuurent folder path we use ".\" so i have applied the technique to get

the dll path which is reside where the test.cpp file is there

now in test.cpp some where else i have written

string str= ".\\test.dll" to get the test.dll path. But i am not getting the dll path into the

my idea is i have to get the path in the variable str="c:\vsproj\example\test\test.dll"

but i am getting ".\test.dll" wat is wrong can u correct me?? variable str; how to get the dll path that in this scenario...

A: 

check with Filemon program. it shows you where the code is trying to search and show you where you do wrong..

ufukgun
+1  A: 

string str= ".\test.dll" to get the test.dll path. But i am not getting the dll path into the

my idea is i have to get the path in the variable str="c:\vsproj\example\test\test.dll"

but i am getting ".\test.dll" wat is wrong can u correct me?? variable str; how to get the dll path that in this scenario...

It's doing exactly what you're asking it to do. What you appear to want it to do isn't going to be achieved this way.

You'll need to get the current working directory and prepend it to "\test.dll", rather than just specifying "\test.dll".

Matthew Iselin
how to get current working directory.........?????/
Cute
In .NET: http://msdn.microsoft.com/en-us/library/system.io.directory.getcurrentdirectory.aspx. Otherwise, look up GetModuleFileName or even _getcwd.
Matthew Iselin
A: 

Using the _getcwd function might be of some aid ;)

Breakthrough
A: 

String has nothing to do with paths. How could it understand what you want? It is just a mere collection of letters.

As others suggested, try using _getcwd and appending "\test.dll" at the end of it.

erelender
A: 

The function you're looking for is GetFullPathName(). It works on C strings, not C++ strings though. Have a look at the examples in the linked article. (You can safely ignore the panicky bits about multi-threaded applications. The same problem actually exists for single-threaded app too. If the current directory changes, ..\xyz\ changes too.)

MSalters
A: 

you can use getcwd(char buf, int len) to get the current working directory:

Inverse