| Author |
Message |
fcomputer |
| Location: |
|
|
Post subject: Sepele tapi GAGAL!!
Posted: 20/Sep/2009 14:23
|
|
onNovice

Joined: 20-Apr-2009
Posts: 14
Status: Offline
|
|
Haduwh2, nie q ada permasalahan tentang bagaimana cara merubah Long FileName ke ShortFileName (DOS), dah Q cari2 n nemu code ini, tapi waktu Q coba tetep gag bisa, apa ada yang salah?? Delphi saya 7.0
Code:
function GetShortName (const FileName: string): string;
var aTmp: array[0..255] of char;
begin
if not FileExists (FileName) then
Result := ''
else if GetShortPathName (PChar (FileName), aTmp, Sizeof (aTmp) - 1) = 0
then
Result:= FileName
else
Result:= StrPas (aTmp);
end;
|
|
|
| |
|
|
|
 |
pebbie |
| Location: di dapur |
|
Post subject: RE: Sepele tapi GAGAL!!
Posted: 20/Sep/2009 14:49
|
|
onUber-Skilled
Joined: 16-Sep-2006
Posts: 459
Location: di dapur
Status: Offline
|
|
| kok pake sizeof? bukannya pake length? |
|
|
| |
|
|
|
 |
fcomputer |
| Location: |
|
Post subject: RE: Sepele tapi GAGAL!!
Posted: 20/Sep/2009 14:51
|
|
onNovice

Joined: 20-Apr-2009
Posts: 14
Status: Offline
|
|
Mungkin kayag gini??
Code:
function GetShortName(sLongName: string): string;
var
sShortName: string;
nShortNameLen: Integer;
begin
SetLength(sShortName, MAX_PATH);
nShortNameLen := GetShortPathName(PChar(sLongName), PChar(sShortName), MAX_PATH - 1);
if (0 = nShortNameLen) then
begin
showmessage('Error!');
end;
SetLength(sShortName, nShortNameLen);
Result := sShortName;
end;
|
|
|
| |
|
|
|
 |
fcomputer |
| Location: |
|
Post subject: RE: Sepele tapi GAGAL!!
Posted: 20/Sep/2009 15:00
|
|
onNovice

Joined: 20-Apr-2009
Posts: 14
Status: Offline
|
|
|
|
|
 |
safari |
| Location: |
|
Post subject: RE: Sepele tapi GAGAL!!
Posted: 21/Sep/2009 07:07
|
|
onConfident

Joined: 13-Aug-2009
Posts: 28
Status: Offline
|
|
|
|
|
 |
|
aday-gate |
| Location: Tangerang-Banten |
|
Post subject: RE: Sepele tapi GAGAL!!
Posted: 22/Sep/2009 06:48
|
|
onConfident
Joined: 23-Jul-2009
Posts: 29
Location: Tangerang-Banten
|
|
pake fungsi "extractfilename" ajah coba... javascript:emoticon(' ') |
_________________ "Newbie 4ever!!!"
|
| |
|
|
|
 |
Penjahat |
| Location: |
|
Post subject: RE: Sepele tapi GAGAL!!
Posted: 23/Sep/2009 19:20
|
|
onIntermediate
Joined: 10-Nov-2007
Posts: 35
Status: Offline
|
|
kedua fungsi milik fcomputer itu kukira bener semua. Tapi sayang fcomputer tidak menjelaskan yg dimaksud dengan gagal.
coba lebih spesifik, mungkin nanti ada yg bisa bantu.
Cantumkan juga apa isi dari parameter sLongName pada kasus anda , dan berapa nilai kembalian dari fungsi API GetShortPathName() |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: Sepele tapi GAGAL!!
Posted: 28/Sep/2009 18:35
|
|
onMage

Joined: 06-Feb-2006
Posts: 2401
|
|
Fungsi ini telah ada di SysUtils.pas
code : pascal uses SysUtils; // berikut cuplikannya function ExtractShortPathName(const FileName: string): string; var Buffer: array[0..MAX_PATH - 1] of Char; begin SetString(Result, Buffer, GetShortPathName(PChar(FileName), Buffer, SizeOf(Buffer))); end;
|
_________________ Dude, if you don't understand the basics and just want to get someone else write the code for you, it means you really shouldn't study computer science. Find a different field.
http://delphiexpert.wordpress.com
|
| |
|
|
|
 |
|
|