tags:

views:

88

answers:

1

When I try to compile my code with the function GetLongPathName(), the compiler tells me that the function is undeclared.

I have already read the MSDN documentation located @ http://msdn.microsoft.com/en-us/library/aa364980%28VS.85%29.aspx. But, even though I included those header files, I am still getting the undeclared function error. Which header file(s) am I supposed to include when using the function?

#include <Windows.h>
#include <WinBase.h>

#define DLLEXPORT extern "C" __declspec(dllexport)

DLLEXPORT char* file_get_long(char* path_original)
{
    long length = 0;
    TCHAR* buffer = NULL;
    if(!path_original)
    {
        return "-10";
    }
    length = GetLongPathName(path_original, NULL, 0);
    if(length == 0)
    {
        return "-10";
    }
    buffer = new TCHAR[length];
    length = GetLongPathName(path_original, buffer, length);
    if(length == 0)
    {
        return "-10";
    }
    return buffer;
}

And, if it makes a difference, I am currently compiling using Dev-C++ on a Windows Vista 64-bit.

+1  A: 

Dev-C++'s support of the Windows API is not complete. Actually, it's not even close. It is entirely likely that the GetLongPathName function is not declared in winbase.h that is shipped with that compiler (Actually an old version of MinGW).

You can use the free compiler which ships with the Windows SDK to work around the problem. It is the same compiler that ships with Visual Studio, though it is commandline only.

You can also use Visual C++ Express Edition, which is free and provides features similar to DevCPP.

Billy ONeal