🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #5515

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

#5515
From: Remy Lebeau (TeamB)
Date: Thu, 11 Aug 2005 06:22
57 lines
2919 bytes
"Oren Halvani" <NoSpam@fdtd.com> wrote in message
news:42fac82b@newsgroups.borland.com...

> thats right, i'm using the BCB3 on this machine...don't laugh :-)
>
> i will use a workaround directly via the API...

You don't need a workaround.  Just load the function dynamically via the
GetProcAddress() function:

    typedef DWORD WINAPI (*LPFN_GLPN)(LPCTSTR, LPTSTR, DWORD cchBuffer);

    #ifdef UNICODE
    #define szGetLongPathName    L"GetLongPathNameW"
    else
    #define szGetLongPathName    "GetLongPathNameW"
    #endif

    #if (__BORLANDC__ < 0x550)
    AnsiString __fastcall IncludeTrailingBackslash(const AnsiString &S)
    {
        if( !IsPathDelimiter(S, S.Length()) )
            return (S + "\\");
        return S;
    }
    #endif

    AnsiString __fastcall TfrmMainUnit::GetTempFile()
    {
        TCHAR TempDir[MAX_PATH + 1] = {0};
        GetTempPath(MAX_PATH, TempDir);

        HMODULE hKernel32 = GetModuleHandle(TEXT("KERNEL32"));
        LPFN_GLPN lpGetLongPathName = (LPFN_GLPN) GetProcAddress(hKernel32,
szGetLongPathName);
        if( lpGetLongPathName )
            lpGetLongPathName(TempDir, TempDir, ARRAYSIZE(TempDir));

        return IncludeTrailingBackslash(TempDir) + "ShowRecord-Tempfile";
    }


> 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

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
Technical Details
Message-ID: <42faeeb4@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.maxwell.syr.edu!msrn-out!msrn-in!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <42fa9d15@newsgroups.borland.com> <42faa901$1@newsgroups.borland.com> <42fab1ed@newsgroups.borland.com> <42fac38d$1@newsgroups.borland.com> <42fac82b@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
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.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> <42fac82b@newsgroups.borland.com>
Subject: Re: GetTempPath() and the ugly "~1"  How to get the *full path*  ??
Date: Wed, 10 Aug 2005 23:22:31 -0700
Lines: 59
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <42faeeb4@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1123741364 68.69.17.41 (10 Aug 2005 23:22:44 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.maxwell.syr.edu!msrn-out!msrn-in!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail