|
|
Home » Community » Newbie corner » How to find the path for a Directory? - Windows (undefined reference to `_imp__PathAppendA@8')
How to find the path for a Directory? - Windows [message #43955] |
Thu, 27 November 2014 14:04  |
rfdiaz
Messages: 4 Registered: November 2014 Location: USA
|
Junior Member |
|
|
Hi,
I'm new to U++ trying to find "paths" under Windows.
This is my test code:
#include "stdio.h"
#include <windows.h>
#include <iostream>
#include "Shlwapi.h"
using namespace std;
int main(int argc, const char *argv[])
{
// String for path name.
char buffer_1[MAX_PATH] = "name_1\\name_2";
char *lpStr1;
lpStr1 = buffer_1;
// String of what is being added.
char buffer_2[ ] = "name_3";
char *lpStr2;
lpStr2 = buffer_2;
cout << "The original path string is " << lpStr1 << endl;
cout << "The part to append to end is " << lpStr2 << endl;
bool ret = PathAppend(lpStr1,lpStr2);
cout << "The appended path string is " << lpStr1 << endl;
return 0;
}
It gives the following error:
PathTest.cpp
PathTest: 1 file(s) built in (0:00.96), 967 msecs / file, duration = 983 msecs, parallelization 0%
Linking...
C:/upp/out/uppsrc/PathTest/MINGW.Debug.Debug_Full.Main.Sse2\ PathTest.o: In function `main':
C:/upp/uppsrc/PathTest/PathTest.cpp:21: undefined reference to `_imp__PathAppendA@8'
collect2.exe: error: ld returned 1 exit status
Maybe this is something obvious yet I have not been able to get it...
Searching on the subject I found a post at StackOverflow which suggests that
"You need to add the shlwapi library for linking:
gcc -o test test.c -lshlwapi"
Thanks for any Path to the solution!!!
Rfdiaz
|
|
|
|
Re: How to find the path for a Directory? - Windows [message #43957 is a reply to message #43955] |
Fri, 28 November 2014 08:37   |
 |
koldo
Messages: 3432 Registered: August 2008
|
Senior Veteran |
|
|
Hello rfdiaz
Welcome to forum.
If you work in U++ you just need AppendFileName() function to append two paths.
If you also wants to browse through a folder, you can use this example:
String path = AppendFileName(dir, "*.*")
FindFile ff(path);
while(ff) {
String name = ff.GetName();
String namePath = AppendFileName(dir, name);
if (ff.IsFile())
DoSomething(namePath);
else if(ff.IsFolder())
DoMore(path, name);
ff.Next();
}
To create a new command line U++ project you have to open TheIDE, choose "New package" and choose this option:

CONSOLE_APP_MAIN is the main() of your program.
-
Attachment: Captur.JPG
(Size: 57.85KB, Downloaded 496 times)
Best regards
IƱaki
[Updated on: Fri, 28 November 2014 08:38] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Sat Apr 26 14:59:26 CEST 2025
Total time taken to generate the page: 0.00782 seconds
|
|
|