水無瀬の部屋 > Programming > sample > sendsend > pathlist.cpp |
---|
1: //*********************************************************
2: // プロジェクト: Send to 'SendTo'
3: // ファイル名: pathlist.cpp
4: //*********************************************************
5: #include "pathlist.h"
6: #include "sendsend.h"
7:
8:
9: //---------------------------------------------------------
10: // ファイルスコープ関数 の 宣言
11: //---------------------------------------------------------
12: static bool CALLBACK EmptyPathListProc( void *ptr, int , const void * );
13: static bool CALLBACK FindDirectoryPathProc( const void *ptr, int , const void *param );
14:
15:
16: //---------------------------------------------------------
17: // ファイルスコープ変数 の 定義
18: //---------------------------------------------------------
19: static const struct
20: {
21: int nCSIDL;
22: DWORD flag;
23: const char *param;
24: }
25: g_pair_sendto[] =
26: {
27: #define sendto_params( name ) { CSIDL_ ## name, SENDTO_ ## name, PARAM_ ## name }
28: sendto_params( STARTMENU ),
29: sendto_params( PROGRAMS ),
30: sendto_params( STARTUP ),
31: sendto_params( ADMINTOOLS ),
32: sendto_params( SENDTO ),
33: sendto_params( FAVORITES ),
34: sendto_params( PERSONAL ),
35: sendto_params( MYPICTURES ),
36: sendto_params( MYMUSIC ),
37: sendto_params( MYVIDEO ),
38: sendto_params( DESKTOPDIRECTORY ),
39: sendto_params( COMMON_STARTMENU ),
40: sendto_params( COMMON_PROGRAMS ),
41: sendto_params( COMMON_STARTUP ),
42: sendto_params( COMMON_ADMINTOOLS ),
43: sendto_params( COMMON_FAVORITES ),
44: sendto_params( COMMON_DOCUMENTS ),
45: sendto_params( COMMON_PICTURES ),
46: sendto_params( COMMON_MUSIC ),
47: sendto_params( COMMON_VIDEO ),
48: sendto_params( COMMON_DESKTOPDIRECTORY ),
49: sendto_params( WINDOWS ),
50: sendto_params( SYSTEM ),
51: #undef sendto_params
52: };
53:
54:
55: //*********************************************************
56: // DestroyPathList
57: //*********************************************************
58: bool
59: DestroyPathList
60: (
61: ptrlist_t *handle
62: )
63: {
64: // パラメタの仮定
65: ASSERT( IsValidPtrListHandle( handle ) );
66:
67: EmptyPtrList( handle, EmptyPathListProc, null );
68:
69: return DestroyPtrList( handle );
70: }//DestroyPathList
71:
72: //*********************************************************
73: // PathList_AddDirectoryPath
74: //*********************************************************
75: int
76: PathList_AddDirectoryPath
77: (
78: ptrlist_t *handle,
79: const char *str
80: )
81: {
82: // パラメタの仮定
83: ASSERT( IsValidStringPtr( str ) );
84: ASSERT( IsValidPtrListHandle( handle ) );
85:
86: //
87: if ( !IsPathDirectory( str ) )
88: return -1;
89: char path[ MAX_PATH_BUF ];
90: if ( !GetLongFileName( str, path, numof(path) ) )
91: return -1;
92: if ( !IsPathDirectory( path ) )
93: return -1;
94:
95: //
96: PtrList_FindItemPtr( handle, true, FindDirectoryPathProc, path );
97:
98: //
99: return PtrList_AddItemBottom( handle, strdup(path) );
100: }//PathList_AddDirectoryPath
101:
102: //*********************************************************
103: // PathList_OpenFolder
104: //*********************************************************
105: bool
106: PathList_OpenFolder
107: (
108: ptrlist_t *folder
109: )
110: {
111: // パラメタの仮定
112: ASSERT( IsValidPtrListHandle( folder ) );
113:
114: const bool bTopdown = true;
115: {for( ptritem_t *item = PtrList_GetBegin( folder, bTopdown );
116: item;
117: item = PtrItem_GetNext( item, bTopdown ) )
118: {
119: const char *path = (char *)PtrItem_GetPtr( item );
120: if ( path && IsPathDirectory( path ) )
121: {
122: MyShellExecute
123: (
124: HWND_DESKTOP,
125: "open",
126: path,
127: null,
128: null,
129: SW_SHOWNORMAL
130: );
131: }
132: }}
133:
134: return true;
135: }//PathList_OpenFolder
136:
137: //*********************************************************
138: // PathList_AddSpecialFolderPath
139: //
140: // pathlist にフラグで指定された特殊フォルダのパスを追加する
141: //
142: //*********************************************************
143: bool
144: PathList_AddSpecialFolderPath
145: (
146: ptrlist_t *pathlist,
147: DWORD flags
148: )
149: {
150: // パラメタの仮定
151: ASSERT( IsValidPtrListHandle( pathlist ) );
152:
153:
154: {for( int i = 0; i < numof( g_pair_sendto ); ++i )
155: {
156: if ( g_pair_sendto[ i ].flag == (flags & g_pair_sendto[ i ].flag) )
157: {
158: char path[ MAX_PATH_BUF ];
159: if ( GetSpecialFolder( HWND_DESKTOP, g_pair_sendto[ i ].nCSIDL, path, numof(path) ) )
160: {
161: PathList_AddDirectoryPath( pathlist, path );
162: }
163: }
164: }}
165:
166: //
167: if ( SENDTO_QUICKLAUNCH == (SENDTO_QUICKLAUNCH & flags) )
168: {
169: char path[ MAX_PATH_BUF ];
170: if ( GetQuickLaunchDirectory( path, numof( path ) ) )
171: {
172: PathList_AddDirectoryPath( pathlist, path );
173: }
174: }
175:
176: return true;
177: }//PathList_AddSpecialFolderPath
178:
179:
180: //******************************************************************************************************************
181: // callback
182: //******************************************************************************************************************
183: //*********************************************************
184: // FindDirectoryPathProc
185: //*********************************************************
186: static
187: bool
188: CALLBACK
189: FindDirectoryPathProc
190: (
191: const void *ptr,
192: int ,
193: const void *param
194: )
195: {
196: // パラメタの仮定
197: ASSERT( IsPathDirectory( (char *)ptr ) );
198: ASSERT( IsValidStringPtr( (char *)param ) );
199:
200: const char *path1 = static_cast<const char *>( ptr );
201: const char *path2 = static_cast<const char *>( param );
202: return streqli( path1, path2 );
203: }//FindDirectoryPathProc
204:
205: //*********************************************************
206: // EmptyPathListProc
207: //*********************************************************
208: static
209: bool
210: CALLBACK
211: EmptyPathListProc
212: (
213: void *ptr,
214: int ,
215: const void *
216: )
217: {
218: // パラメタの仮定
219: ASSERT( IsPathDirectory( (char *)ptr ) );
220:
221: free( ptr );
222:
223: return true;
224: }//EmptyPathListProc
225:
226:
227: //** end **
228:
参照:
水無瀬の部屋 > sample > sendsend > pathlist.cpp |
---|
このページは cpp2web が出力しました。
水無瀬 優 postmaster@katsura-kotonoha.sakura.ne.jp
http://katsura-kotonoha.sakura.ne.jp/prog/code/sendsend/pathlist_cpp.shtml
>> Amazon.co.jp 『たまゆら童子』 へ
>> 楽天ブックス 『たまゆら童子』 へ