다음을 참고하셔서 보면 됩니다. 바탕화면뿐만 아니라 다른 폴더도 참고하세요
참 uses 절에 shlobj를 추가하세요 그럼 즐프하세요..^^
//====================================================================
// OS의 Version을 인식하기 위한 Function .....
// 1: Win 3.1, 2: Win95, 3: Win98, 4: WinNT3 5: WinNT4, 6: Win2000, 7: WinMe
//====================================================================
Function FindOSVersion : Integer ;
Var
myVersionInfo : TOSVersionInfo ;
Begin
FillChar ( myVersionInfo, SizeOf(myVersionInfo), #0 ) ;
myVersionInfo.dwOSVersionInfoSize := SizeOf ( myVersionInfo ) ;
If ( GetVersionEx( myVersionInfo ) = False ) Then
Begin
Result := -1 ; //error
Exit ;
End ;
Case myVersionInfo.dwPlatformId Of
VER_PLATFORM_WIN32S:
Begin
Result := 1; // Win3.1
End ;
VER_PLATFORM_WIN32_WINDOWS:
Begin
If (myVersionInfo.dwMajorVersion = 5) Then
Begin
Result := 7; // WinMe
End
Else
If (myVersionInfo.dwMinorVersion = 0) Then
Begin
Result := 2; // Win95
End
Else If (myVersionInfo.dwMinorVersion > 0) Then
Begin
Result := 3; // Win98
End ;
End ;
VER_PLATFORM_WIN32_NT:
Begin
Case myVersionInfo.dwMajorVersion of
3: Result := 4; // WinNT 3
4: Result := 5; // WinNT 4
5: Result := 6; // Win2000
End ;
End ;
End ;
end;
WinNT
0016 : all users시작메뉴
0017 : all users시작메뉴프로그램
0018 : 프로그램시작프로그램
0019 : 바탕화면
001a : application data
001b : printhood
001c : local settingapplication data
001f : all usersfavorite
0020 : local settingstemporery internet files
0021 : cookies
0022 : local settingshistory
0023 : all usersapplication data
0024 : c:winnt
0025 : c:winntsystem32
0026 : c:program files
0027 : mydocumentsmypicture
0028 : document and settingsusername
0029 : c:winntsystem32
002b : c:program filescommon files
002d : all userstemplates
002e : all usersdocuments
002f : all users시작메뉴프로그램관리도구
0030 : username시작메뉴프로그램관리도구
}
procedure TForm1.BitBtn1Click(Sender: TObject);
var
pidl : PItemIDList;
hRes : HRESULT;
Success : bool;
RealPath : Array[0..MAX_PATH] of Char;
Location : string;
begin
case FindOSVersion of
1 : hRes := SHGetSpecialFolderLocation(self.Handle,$0000,pidl); //Windows 3.1.
2 : hRes := SHGetSpecialFolderLocation(self.Handle,$0000,pidl); //Windows 95.
3 : hRes := SHGetSpecialFolderLocation(self.Handle,$0000,pidl); //Windows 98.
4 : hRes := SHGetSpecialFolderLocation(self.Handle,$0019,pidl); //Windows NT 3.
5 : hRes := SHGetSpecialFolderLocation(self.Handle,$0019,pidl); //Windows NT 4.
6 : hRes := SHGetSpecialFolderLocation(self.Handle,$0019,pidl); //Windows 2000.
7 : hRes := SHGetSpecialFolderLocation(self.Handle,$0000,pidl); //Windows ME.
end;
// Program files directory 구하기
if hRes = NO_ERROR then
begin
Success := SHGetPathFromIDList( pidl, RealPath );
if Success then
begin
Location := String( RealPath ) + ''
end else
begin
// Result := LongWord( E_UNEXPECTED );
showmessage(inttostr(LongWord( E_UNEXPECTED )));
end;
showmessage('ok:'+Location);
end;
다음을 참고하셔서 보면 됩니다. 바탕화면뿐만 아니라 다른 폴더도 참고하세요
참 uses 절에 shlobj를 추가하세요 그럼 즐프하세요..^^
//====================================================================
// OS의 Version을 인식하기 위한 Function .....
// 1: Win 3.1, 2: Win95, 3: Win98, 4: WinNT3 5: WinNT4, 6: Win2000, 7: WinMe
//====================================================================
Function FindOSVersion : Integer ;
Var
myVersionInfo : TOSVersionInfo ;
Begin
FillChar ( myVersionInfo, SizeOf(myVersionInfo), #0 ) ;
myVersionInfo.dwOSVersionInfoSize := SizeOf ( myVersionInfo ) ;
If ( GetVersionEx( myVersionInfo ) = False ) Then
Begin
Result := -1 ; //error
Exit ;
End ;
Case myVersionInfo.dwPlatformId Of
VER_PLATFORM_WIN32S:
Begin
Result := 1; // Win3.1
End ;
VER_PLATFORM_WIN32_WINDOWS:
Begin
If (myVersionInfo.dwMajorVersion = 5) Then
Begin
Result := 7; // WinMe
End
Else
If (myVersionInfo.dwMinorVersion = 0) Then
Begin
Result := 2; // Win95
End
Else If (myVersionInfo.dwMinorVersion > 0) Then
Begin
Result := 3; // Win98
End ;
End ;
VER_PLATFORM_WIN32_NT:
Begin
Case myVersionInfo.dwMajorVersion of
3: Result := 4; // WinNT 3
4: Result := 5; // WinNT 4
5: Result := 6; // Win2000
End ;
End ;
End ;
end;
//각폴더의 핸들값은 다음과 같습니다.
{Win9X
0000 : 바탕화면
0002 : 시작메뉴프로그램
0005 : my document
0006 : favorite
0007 : 프로그램시작프로그램
0008 : recent
0009 : sendto
000b : 시작메뉴
0010 : 바탕화면
0013 : nethood
0014 : fonts
0015 : templete
WinNT
0016 : all users시작메뉴
0017 : all users시작메뉴프로그램
0018 : 프로그램시작프로그램
0019 : 바탕화면
001a : application data
001b : printhood
001c : local settingapplication data
001f : all usersfavorite
0020 : local settingstemporery internet files
0021 : cookies
0022 : local settingshistory
0023 : all usersapplication data
0024 : c:winnt
0025 : c:winntsystem32
0026 : c:program files
0027 : mydocumentsmypicture
0028 : document and settingsusername
0029 : c:winntsystem32
002b : c:program filescommon files
002d : all userstemplates
002e : all usersdocuments
002f : all users시작메뉴프로그램관리도구
0030 : username시작메뉴프로그램관리도구
}
procedure TForm1.BitBtn1Click(Sender: TObject);
var
pidl : PItemIDList;
hRes : HRESULT;
Success : bool;
RealPath : Array[0..MAX_PATH] of Char;
Location : string;
begin
case FindOSVersion of
1 : hRes := SHGetSpecialFolderLocation(self.Handle,$0000,pidl); //Windows 3.1.
2 : hRes := SHGetSpecialFolderLocation(self.Handle,$0000,pidl); //Windows 95.
3 : hRes := SHGetSpecialFolderLocation(self.Handle,$0000,pidl); //Windows 98.
4 : hRes := SHGetSpecialFolderLocation(self.Handle,$0019,pidl); //Windows NT 3.
5 : hRes := SHGetSpecialFolderLocation(self.Handle,$0019,pidl); //Windows NT 4.
6 : hRes := SHGetSpecialFolderLocation(self.Handle,$0019,pidl); //Windows 2000.
7 : hRes := SHGetSpecialFolderLocation(self.Handle,$0000,pidl); //Windows ME.
end;
// Program files directory 구하기
if hRes = NO_ERROR then
begin
Success := SHGetPathFromIDList( pidl, RealPath );
if Success then
begin
Location := String( RealPath ) + ''
end else
begin
// Result := LongWord( E_UNEXPECTED );
showmessage(inttostr(LongWord( E_UNEXPECTED )));
end;
showmessage('ok:'+Location);
end;
end;