Board index » cppbuilder » Re: GetTempPath() and the ugly "~1" How to get the *full path* ??

Re: GetTempPath() and the ugly "~1" How to get the *full path* ??


2005-08-11 10:03:26 AM
cppbuilder15
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >schrieb im Newsbeitrag
Quote
So? Just because portions of the path are in 8.3 format does not mean that
the path is invalid, because it is not. You can still use 8.3 paths in
modern operations just fine.
i know, i know :-)
Quote
Why do you care whether you have a short path or a long path? Both work
equally as well.
again: i know, but i have to show the user the full path + file...if i would use it
internal in the program, i realy wouldn't care about it:-)
Quote
If you must get the long name, then pass the short path to either
GetLongPathName() or FindFirstFile().
Remy, i've tryed: GetLongPathName() but the compiler didn't recognized it
what do i need to include..? i've choosed FindFirstFile() instead,
but it returns me ONLY the filename !
i need the full path + filename...
here's what i got...don't expect too much i'm very, very tired :-)
/*********************************************************/
AnsiString TfrmMainUnit::GetTempFile()
{
char TempDir[MAX_PATH + 1]; TempDir[MAX_PATH] = '\0';
GetTempPath(MAX_PATH, TempDir);
String filename = "ShowRecord-Tempfile",
newPath = TempDir + filename;
WIN32_FIND_DATA FindFileData;
HANDLE hFind = FindFirstFile(newPath.c_str(), &FindFileData);
if(hFind != INVALID_HANDLE_VALUE)
{
FindClose(hFind);
//ShowMessage(FindFileData.cFileName); // Check before returning..
return(FindFileData.cFileName);
}
else
{
ShowMessage("Invalid File Handle. GetLastError reports: " + GetLastError());
return(0);
}
}
 
 

Re:Re: GetTempPath() and the ugly "~1" How to get the *full path* ??

this is strange, at the MSDN i've seen this:
--------------------------------------------------------------
typedef struct _WIN32_FIND_DATA
{
DWORD dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD nFileSizeHigh;
DWORD nFileSizeLow;
DWORD dwReserved0;
DWORD dwReserved1;
TCHAR cFileName[MAX_PATH];
TCHAR cAlternateFileName[14];
}
WIN32_FIND_DATA,
*PWIN32_FIND_DATA,
*LPWIN32_FIND_DATA;
--------------------------------------------------------------
so the next question in how do i get the path additional to the
cFileName...?
Oren
 

Re:Re: GetTempPath() and the ugly "~1" How to get the *full path* ??

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >schrieb im Newsbeitrag
Quote
You don't need a workaround. Just load the function dynamically via the
GetProcAddress() function:
[snip...]
thanks alot for the sample..
Quote
It already is. The entire Win32 API is implemented in DLLs that are shipped
with the OS. Every application already implicitally links to USER32.DLL,
KERNEL32.DLL, and SHELL32.DLL. Those three DLLs implement the bulk of the
API.


Gambit
Remy i know,
but there are several version of those files available...that means will the program run
also under Win9.x or is the GetLongPathName() not implemented there......?
that is what i'm afraid of.....
where can i check the version-history of the API files....? i didn't found something
like that at the MSDN website....
Oren
 

{smallsort}