Article View: borland.public.cppbuilder.nativeapi
Article #5514Re: GetTempPath() and the ugly "~1" How to get the *full path* ??
From: Oren Halvani
Date: Thu, 11 Aug 2005 03:38
Date: Thu, 11 Aug 2005 03:38
132 lines
4931 bytes
4931 bytes
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> schrieb im Newsbeitrag
news:42fac38d$1@newsgroups.borland.com...
> You seriously need to learn to start reading documentation before you ask
> such things.
this is what i was trying first :-)
> You don't need to include anything for GetLongPathName(). It is declared
> in
> winbase.h, which is included by windows.h, which is included by vcl.h. In
> other words, the function is always available.
>
> If the compiler does not recognize the function, then you must be using
> BCB
> 1 or 3, because GetLongPathName() has been available to Borland since
> BCB4.
>
>
> Gambit
thats right, i'm using the BCB3 on this machine...don't laugh :-)
i will use a workaround directly via the API...because, like
i've said FindFirstFile() doesn't give me the full path + filename....
that's way i'm depend on this GetLongPathName()
besides this i like the API more as the VCL because it's more
transparent, so it's possible to see what goes on behind the curtain :-)
by the way, when i'm including: <windows.h>
which DLL's will be effected, will it be still standalone...? this
is something that i never understand, i mean if you want to use
a specific function that is declared in the huge <windows.h>
will your program will be depening on all those lib's and DLL's
or only on those of the specific function that you want to use....?
Oren
here's a little sample from the MSDN:
---------------------------------------------------------------------
#include <windows.h>
#include <stdio.h>
#define BUFSIZE 4096
int main(int argc, char *argv[])
{
DWORD retval=0;
BOOL success;
char buffer[BUFSIZE]="";
char * lpPart[BUFSIZE]={NULL};
// Retrieve a full path name for a file. The file does not need to
// exist.
retval = GetFullPathName("c:\\testfile.txt",
BUFSIZE,
buffer,
lpPart);
if (retval == 0)
{
// Handle an error condition.
printf ("GetFullPathName failed with error %d.\n",
GetLastError());
return (1);
}
else
printf("The full path name for the file test.txt is: %s\n",
buffer);
// Create a long directory name for use with the next two examples.
success = CreateDirectory("c:\\longdirectoryname",
NULL); // No security attributes.
if (!success)
{
// Handle an error condition.
printf ("CreateDirectory failed with error %d.\n",
GetLastError());
return (1);
}
// Retrieve the short path name.
retval = GetShortPathName("c:\\longdirectoryname",
buffer,
BUFSIZE);
if (retval == 0)
{
// Handle an error condition.
printf ("GetShortPathName failed with error %d.\n",
GetLastError());
return (1);
}
else
printf("The short path name for the directory "
"c:\\longdirectoryname is: %s\n", buffer);
// Retrieve the long path name.
retval = GetLongPathName("c:\\LONGDI~1",
buffer,
BUFSIZE);
if (retval == 0)
{
// Handle an error condition.
printf ("GetLongPathName failed with error %d.\n",
GetLastError());
return (1);
}
else
printf("The long path name for the directory "
"c:\\longdirectoryname is: %s\n", buffer);
// Clean up the directory.
success = RemoveDirectory("c:\\longdirectoryname");
if (!success)
{
// Handle an error condition.
printf ("RemoveDirectory failed with error %d.\n",
GetLastError());
return (1);
}
}
Technical Details
Message-ID:
<42fac82b@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!solnet.ch!solnet.ch!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<42fa9d15@newsgroups.borland.com> <42faa901$1@newsgroups.borland.com> <42fab1ed@newsgroups.borland.com> <42fac38d$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,420a348eb6918014 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Oren Halvani" <NoSpam@fdtd.com> From: "Oren Halvani" <NoSpam@fdtd.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <42fa9d15@newsgroups.borland.com> <42faa901$1@newsgroups.borland.com> <42fab1ed@newsgroups.borland.com> <42fac38d$1@newsgroups.borland.com> Subject: Re: GetTempPath() and the ugly "~1" How to get the *full path* ?? Date: Thu, 11 Aug 2005 05:38:19 +0200 Lines: 134 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 84.176.107.114 Message-ID: <42fac82b@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1123731499 84.176.107.114 (10 Aug 2005 20:38:19 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!solnet.ch!solnet.ch!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail