|
From: Lennart B. <len...@st...> - 2006-12-01 14:46:55
|
Brian Dessent wrote: > Lennart Borgman wrote: > >>> I get the abover error when trying to link a program using >>> GetLongPathName. It also uses GetFullPathName which I have had no >>> trouble with. They are both in kernel32. >>> >>> What is wrong here? What do I need to link? > > [ Why is this text quoted? Who are you quoting? Who's talking? Why > obfuscate your text in this way? ] Sorry, forgot that I had unsubscribed due to the amount of mail I get from different sources. My message was on hold and I subscribed again and canceled the message that was on hold. > The answer is that there is actually no such function GetLongPathName in > kernel32, there is an ANSI version (GetLongPathNameA) and a wide > character/Unicode version (GetLongPathNameW). GetLongPathName is > #defined in winbase.h to one of these based on whether you've enabled > Unicode or not. So the prolem you are having is due to an issue with > your includes, not a linking problem. You need to make sure that you've > included <windows.h> properly. > > This can also occur if you somehow managed to declare the function > prototype without the WINAPI qualifier, as the compiler will use the > default but wrong cdecl calling convention which has no decoration. But > you should not be declaring this function, it should be declared by > winbase.h (which is included by windows.h.) > > In short, look at the preprocessed source of your code, after all macro > expansions and includes have occurred, and make sure that the above two > things have been satisfied. Thanks, after reading you message I looked a bit more in the header files. Nothing was wrong there, but I was surprised that GetLongPathName was not declared in NT4. I had _WIN32_WINNT set to 0x0400. (I have not set up this. In fact I know too little myself about C programming.) The reason I wanted to test GetLongPathName was to find out if the syntax for a file name is correct. GetLongPathName actually seems to do that, but just if the file exists. This is another question and off topic here perhaps, but is there a better API for checking file name syntax? |