2 * COMMDLG - File Dialogs
4 * Copyright 1994 Martin Ayotte
5 * Copyright 1996 Albrecht Kleine
14 #include "heap.h" /* Has to go */
16 DEFAULT_DEBUG_CHANNEL(commdlg
)
20 /***********************************************************************
21 * GetFileTitleA (COMDLG32.8)
24 short WINAPI
GetFileTitleA(LPCSTR lpFile
, LPSTR lpTitle
, UINT cbBuf
)
28 TRACE(commdlg
,"(%p %p %d); \n", lpFile
, lpTitle
, cbBuf
);
30 if(lpFile
== NULL
|| lpTitle
== NULL
)
38 if(strpbrk(lpFile
, "*[]"))
43 if(lpFile
[len
] == '/' || lpFile
[len
] == '\\' || lpFile
[len
] == ':')
46 for(i
= len
; i
>= 0; i
--)
48 if (lpFile
[i
] == '/' || lpFile
[i
] == '\\' || lpFile
[i
] == ':')
58 TRACE(commdlg
,"---> '%s' \n", &lpFile
[i
]);
60 len
= strlen(lpFile
+i
)+1;
64 strncpy(lpTitle
, &lpFile
[i
], len
);
69 /***********************************************************************
70 * GetFileTitleW (COMDLG32.9)
73 short WINAPI
GetFileTitleW(LPCWSTR lpFile
, LPWSTR lpTitle
, UINT cbBuf
)
75 LPSTR file
= HEAP_strdupWtoA(GetProcessHeap(), 0, lpFile
); /* Has to go */
76 LPSTR title
= HeapAlloc(GetProcessHeap(), 0, cbBuf
);
79 ret
= GetFileTitleA(file
, title
, cbBuf
);
81 lstrcpynAtoW(lpTitle
, title
, cbBuf
);
82 HeapFree(GetProcessHeap(), 0, file
);
83 HeapFree(GetProcessHeap(), 0, title
);
88 /***********************************************************************
89 * GetFileTitle16 (COMMDLG.27)
91 short WINAPI
GetFileTitle16(LPCSTR lpFile
, LPSTR lpTitle
, UINT16 cbBuf
)
93 return GetFileTitleA(lpFile
, lpTitle
, cbBuf
);