其他分享
首页 > 其他分享> > C语言获取当前的用户桌面

C语言获取当前的用户桌面

作者:互联网

#include <windows.h>
#include <ShlObj.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <direct.h>
#include <io.h>
/**
 * 得到当前用户的桌面
 */
unsigned char getDesktoppath(char path[])
{
	CHAR szDesktop[MAX_PATH];
	LPITEMIDLIST pidl = NULL;
	SHGetFolderLocation(NULL, CSIDL_DESKTOPDIRECTORY, NULL, 0, &pidl);
	SHGetPathFromIDList(pidl, szDesktop);
	strcpy(path, szDesktop);
}
int main() {
	char szDesktop[MAX_PATH];
	getDesktoppath(szDesktop);
	printf("%s\n", szDesktop);
}

 

标签:NULL,桌面,pidl,C语言,char,获取,PATH,include,szDesktop
来源: https://blog.csdn.net/github_37687123/article/details/121203612