Bonjour à tou(te)s
Je viens de terminer un petit prog utilitaire tout simple, qui installe une police de caractère sur le PC. L'utilisateur désigne un fichier fonte dans un opendialog...
Begin
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
   chemin:=extractfilepath(paramstr(0));
   opendialog.InitialDir:=chemin;
   opendialog.Execute;
   source:=opendialog.filename;
   if source='' then close;
   destination:='C:\WINDOWS\Fonts\'
   +rightstr(opendialog.filename,pos('\',reversestring(opendialog.filename))-1);
   case fileexists(destination) of
   false: begin
         if messagedlg('Installer la police de caratères'+chr(10)
            +rightstr(opendialog.filename,pos('\',reversestring(opendialog.filename))-1)+' ?',mtConfirmation,mbOKCancel,0)
            =mrno then close;
         MoveFileEx(PChar(Source), PChar(Destination),MOVEFILE_COPY_ALLOWED);
         showmessage(rightstr(opendialog.filename,pos('\',reversestring(opendialog.filename))-1)
         +chr(10)+'installation réussie');close;end;
   true: begin
         showmessage('La police de caractères'+chr(10)+
         rightstr(opendialog.filename,pos('\',reversestring(opendialog.filename))-1)
         +chr(10)+'est déjà installée');close;end;
   end;
ça marche bien sous xp
En revanche sous 98, le fichier n'est pas déplacé et win n'affiche aucun message d'erreur