Desktop Directory

Started by
6 comments, last by Colin Jeanne 16 years, 11 months ago
Hi, Does anyone know how to get the desktop directory for the current user via win32? I tried this:

#include <windows.h>
#include <shlobj.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
	char buf[4096];
	SHGetFolderPath(NULL,CSIDL_DESKTOPDIRECTORY,0,SHGFP_TYPE_CURRENT,buf);
	printf("directory: %s\n",buf);
	return 0;
}
But MSVC6 complains, 'SHGetFolderPath' : undeclared identifier. even though the MSDN claims the function is in shlobj.h (http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/reference/functions/shgetfolderpath.asp?frame=true) Thanks.
Advertisement
Before including windows.h you need to have

#define NTDDI_VERSION NTDDI_WIN2K

if using the most recent Platform SDK or

#define _WIN32_WINNT 0x0500

if using an older Platform SDK.
<Obligatory MSVC6 Is Bad™ Post>

MSVC 6 Is Bad™ - MSVC 8 (2005) is freely available and is far superior in every way. MSVC 6 was produced before the C++ standard was finalized, so it's support for C++ is very poor and it's standard library is not at all conformant.

You would do yourself a great service to upgrade to the freely available version of MSVC 8.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
I realize that vc++6 is bad, but if you combine it with stlport, is it still as awful as it is made out to be? (we are a 7.1 shop ourselves)
Quote:Original post by metiscus
I realize that vc++6 is bad, but if you combine it with stlport, is it still as awful as it is made out to be? (we are a 7.1 shop ourselves)


It handles templates like a drunk man in a china shop. :)
Quote:Original post by metiscus
I realize that vc++6 is bad, but if you combine it with stlport, is it still as awful as it is made out to be? (we are a 7.1 shop ourselves)
Yes, it really is. The STL implementation is just one of the things that's screwed up with VC6. There's templates as dmail mentioned, the optimiser can generate broken code, the code it generates isn't nearly as optimal as VC2005 can generate, it's over 10 years old now, and there's a lot of SDKs that aren't supported with it (E.g. the DirectX SDKs from the last year and a half).
Colin Jeanne: Thanks for the tip, got it working now!

Extrarius/vc6 debate:
Yes, I have VC6, VC7 (although not installed), VC7.1 and VC8, and I agree VC8 is a great compiler - a first for MS, and VS2005 is a great IDE.

That being said, I know the VC6 compiler fairly well, I never need to worry about manifest files and such nonsense, it produces smaller executables, the IDE uses only 8mb ram instead of >100, the interface is fast, basically, its awesome for small projects. (read: <3k LOC, single exe distributable)

If I'm doing anything bigger where I'm likely to consider doing something using advanced templates (vc6's template support isn't THAT broken), then I'll boot up VC8.
I should mention, new versions of the Platform SDK dont support MSVC++ 6.0, if I recall correctly.

Further, you dont need to worry about manifest files, etc. unless you want to. Everything that you're doing now in 6.0 can be done in pretty much the exact same way in 8.0.

This topic is closed to new replies.

Advertisement