简体   繁体   中英

how do I add a GetCurrentDirectory file? C++ [solved]

Question, how do I add a GetCurrentDirectory file? I have this code:

const unsigned long maxDir = 260;
         char currentDir [maxDir] = "";
         GetCurrentDirectory (maxDir, currentDir);
std :: cout << currentDir << std :: endl;

ok but if I want to add a file std :: cout << currentDir + "mydll.dll" << std :: endl;

it gives me an error.

How can I include the current directory + the file?

It is to inject a dll.

LPCSTR DllPath = currentDir + "mydll.dll";

Thank you so much.

solution: You must use strcpy() and strcat() for C-style strings. Alternatively, you can use std::string, which would allow you to use the + operator in the way that you intended

Thanks a lot: Andreas Wenzel

I think you are missing by the actual path. You should do like below(if it is a Linux) "CurrentDir/FileName" std :: cout << currentDir + "\\" + "mydll.dll" << std :: endl;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM