Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "WinAPI";
Текущий архив: 2003.07.07;
Скачать: [xml.tar.bz2];

Вниз

Работа с GetFullPathName()   Найти похожие ветки 

 
3223(jab)   (2003-04-29 10:35) [0]

Не знаю, как в дельфи правильно с ней работать? Она мне не возвращает полного пути...


 
Anatoly Podgoretsky   (2003-04-29 10:40) [1]

This function does not handle ".." path components in lpFileName.


 
3223(jab)   (2003-04-29 10:48) [2]

procedure TForm1.FormCreate(Sender: TObject);
var
lpFileName:LPCTSTR;
nBufferLength:DWORD;
lpBuffer,lpFilePart:LPTSTR;
begin
lpFileName:=PChar((ParamStr(1)));
nBufferLength:=Length(ParamStr(1))+1;
lpBuffer:=PChar(ParamStr(1));
GetFullPathName(Pointer(lpFileName),nBufferLength,Pointer(lpBuffer),lpFilePart);
Edit1.Text:=lpBuffer+" "+lpFilePart;
end;

Что то подобное... и ... и как я не ставил поинты... не работает


 
Anatoly Podgoretsky   (2003-04-29 10:56) [3]

Память будет Пушкин выделять?


 
3223(jab)   (2003-04-29 11:01) [4]

GetMem(); Сколько и какой????


 
Cobalt   (2003-04-29 11:26) [5]

If the lpBuffer buffer is too small, the return value is the size of the buffer, in characters, required to hold the path.

Кто будет анализировать возвращаемое значение?
ShowMessage(SysErrorMessage(GetLastError));


 
3223(jab)   (2003-04-29 12:38) [6]

А зачем мне анализировать? Мнеб кусок кода, чтоб я мог разобраться что и к чему (что писать в какой последовательности)


 
Anatoly Podgoretsky   (2003-04-29 12:50) [7]

Ну если не получается работать с АПИ, то используй ExpandFileName или совсем просто GetCurrentDir + FileName


 
Игорь Шевченко   (2003-04-29 12:53) [8]

The GetFullPathName function merges the name of the current drive and directory with the specified filename to determine the full path and filename of the specified file. It also calculates the address of the filename portion of the full path and filename. This function does not verify that the resulting path and filename are valid or that they refer to an existing file on the associated volume.

GetFullPathName does no conversion of the specified file name, lpFileName. If the specified file name exists, you can use GetLongPathName and GetShortPathName to convert to long and short path names, respectively.



 
stel   (2003-04-30 16:33) [9]

function GetLongName(const FileName: string): string;
var
GetLongPathName: function (pszShortName, pszLongName: PChar;
cchBuffer: Integer): Integer stdcall;
Handle: HINST;
Buffer: array[0..MAX_PATH-1] of AnsiChar;

function InternalGetLongName(FileName: string): string;
var
SearchRec: TSearchRec;
FindResult: Integer;
Path, S1, S2, SN: string;
begin
if (FileName = "") or
(GetFileAttributes(PChar(FileName)) = $FFFFFFFF) then begin
Result:="";
Exit;
end;
Path:=ExtractFilePath(FileName);
S1:=FileName;
Delete(S1, 1, 1);
if (Path<>"") and (S1<>":") and (S1<>"\") then begin
FindResult:=FindFirst(Path+"*.*", faAnyFile, SearchRec);
try
Result:=FileName;
SN:=_ExtractFileName(FileName);
while FindResult = 0 do begin
S2:=SearchRec.Name;
if (SN = S2) or (SN = SearchRec.FindData.cAlternateFileName) then begin
Result:=InternalGetLongName(ExcludeTrailingBackslash(Path))+"\"+S2;
Break;
end;
FindResult:=FindNext(SearchRec);
end;
finally
FindClose(SearchRec);
end;
end else Result:=FileName;
end;
begin
Handle:=GetModuleHandle("kernel32.dll");
@GetLongPathName:=GetProcAddress(handle, "GetLongPathNameA");
if Assigned(GetLongPathName) then begin
if GetLongPathName(PChar(FileName), @Buffer[0], SizeOf(Buffer))<>0
then Result:=PChar(@Buffer[0]) else Result:=FileName;
end else Result:=InternalGetLongName(FileName);
end;


 
3223(jab)   (2003-05-05 11:15) [10]

Ок! Спасибки.



Страницы: 1 вся ветка

Форум: "WinAPI";
Текущий архив: 2003.07.07;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.46 MB
Время: 0.008 c
14-20301
postx
2003-06-20 15:21
2003.07.07
Ищу генератор API


1-20147
lightix
2003-06-24 16:18
2003.07.07
QReport - как программно сменить принтер?


1-20095
Mihey
2003-06-24 00:45
2003.07.07
Общее событие OnClick для нескольких контролов...


9-19946
Ёгурт
2002-12-15 18:57
2003.07.07
А какой алгоритм у крестиков и ноликов


3-20004
Солер
2003-06-11 13:58
2003.07.07
Помогите с запросом





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский