1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
function TForm1.ConnecterLecteurReseau(Serveur:pchar;PartageServeur:pchar;
codeUtilisateur:pchar;motpasseUtilisateur:pchar): boolean;
var lpNetRessource:TNetResource;
Resultat:DWord;
tampon,erreur:string;
begin
lpNetRessource.dwType:=RESOURCETYPE_ANY;
lpNetRessource.lpLocalName:='';
tampon := '\\'+ Serveur + '\' + PartageServeur ;
lpNetRessource.lpRemoteName:= pchar(tampon);
lpNetRessource.lpProvider:=nil;
Resultat:=WNetAddConnection2(lpNetRessource,MotPasseUtilisateur,codeUtilisateur,0);
if (Resultat<>NO_ERROR) OR (Resultat<>ERROR_SESSION_CREDENTIAL_CONFLICT) then Result:=False;
case resultat of
NO_ERROR :Result:=True;
ERROR_SESSION_CREDENTIAL_CONFLICT : begin
erreur:='ERROR_SESSION_CREDENTIAL_CONFLICT'+#13+'Vous êtes peut être déja loggé ?';
Result:= true ;
end;
ERROR_ACCESS_DENIED : erreur:='Accès refusé';
ERROR_ALREADY_ASSIGNED : erreur:='Lecteur réseau déjà attribué';
ERROR_INVALID_PASSWORD : erreur:='Mot de passe incorrect';
ERROR_BAD_NET_NAME : erreur:='Erreur de connexion à votre répertoire réseau (nom réseau)';
ERROR_LOGON_FAILURE : erreur:='ERROR_LOGON_FAILURE';
ERROR_NOT_READY : erreur:='ERROR_NOT_READY';
ERROR_NOT_DOS_DISK : erreur:='ERROR_NOT_DOS_DISK';
ERROR_READ_FAULT : erreur:='ERROR_READ_FAULT';
ERROR_SHARING_VIOLATION : erreur:='ERROR_SHARING_VIOLATION';
ERROR_NOT_SUPPORTED : erreur:='ERROR_NOT_SUPPORTED';
ERROR_NETWORK_BUSY : erreur:='ERROR_NETWORK_BUSY';
ERROR_DEV_NOT_EXIST : erreur:='ERROR_DEV_NOT_EXIST';
ERROR_NETNAME_DELETED : erreur:='ERROR_NETNAME_DELETED';
ERROR_NETWORK_ACCESS_DENIED : erreur:='ERROR_NETWORK_ACCESS_DENIED';
ERROR_TRUST_FAILURE : erreur:='ERROR_TRUST_FAILURE';
ERROR_FILE_NOT_FOUND : erreur:='The system cannot find the file specified.';
ERROR_PATH_NOT_FOUND : erreur:='The system cannot find the path specified.';
ERROR_TOO_MANY_OPEN_FILES : erreur:='The system cannot open the file.';
ERROR_INVALID_HANDLE : erreur:='The handle is invalid.';
ERROR_ARENA_TRASHED : erreur:='The storage control blocks were destroyed.';
ERROR_NOT_ENOUGH_MEMORY : erreur:='Not enough storage is available to process this command.';
ERROR_INVALID_BLOCK : erreur:='The storage control block address is invalid.';
ERROR_BAD_ENVIRONMENT : erreur:='The environment is incorrect.';
ERROR_BAD_FORMAT : erreur:='An attempt was made to load a program with an incorrect format.';
ERROR_INVALID_ACCESS : erreur:='The access code is invalid.';
ERROR_INVALID_DATA : erreur:='The data is invalid.';
ERROR_OUTOFMEMORY : erreur:='Not enough storage is available to complete the operation.';
ERROR_INVALID_DRIVE : erreur:='The system cannot find the drive specified.';
ERROR_CURRENT_DIRECTORY : erreur:='The directory cannot be removed.';
ERROR_NOT_SAME_DEVICE : erreur:='The system cannot move the file to a different disk drive.';
ERROR_NO_MORE_FILES : erreur:='There are no more files.';
ERROR_WRITE_PROTECT : erreur:='Error, The write protect is set';
ERROR_BAD_UNIT : erreur:='Error, The system cannot find the device';
ERROR_BAD_COMMAND : erreur:='The device does not recognize the command.';
ERROR_CRC : erreur:='Data error (cyclic redundancy check).';
ERROR_BAD_LENGTH : erreur:='Incorrect command length from program';
ERROR_SEEK : erreur:='The drive cannot locate a specfic area or track on the disk';
ERROR_SECTOR_NOT_FOUND : erreur:='The drive cannot find the sector requested.';
ERROR_OUT_OF_PAPER : erreur:='The Printer is out of paper.';
ERROR_WRITE_FAULT : erreur:='The system cannot read from the specified device.';
ERROR_GEN_FAILURE : erreur:='A device attached to the system is not functioning.';
ERROR_LOCK_VIOLATION : erreur:='Another process has locked the file.';
ERROR_WRONG_DISK : erreur:='The wrong diskette is in the drive.';
ERROR_SHARING_BUFFER_EXCEEDED : erreur:='Too many files opened for sharing.';
ERROR_HANDLE_EOF : erreur:='Reached end of file';
ERROR_HANDLE_DISK_FULL : erreur:='The disk is full';
ERROR_MORE_DATA : erreur:='More data is available';
ERROR_END_OF_MEDIA : erreur:='Error, End of media';
ERROR_FILEMARK_DETECTED : erreur:='Error, Filemark detected';
ERROR_BEGINNING_OF_MEDIA: erreur:='Error, Cannot access data before medium marker';
ERROR_SETMARK_DETECTED : erreur:='Error, A setmark was reached';
ERROR_NO_DATA_DETECTED : erreur:='Error, Eof of data marker reached';
ERROR_PARTITION_FAILURE : erreur:='Error, The tape could not be partitioned';
ERROR_INVALID_BLOCK_LENGTH : erreur:='Error, The Block size is incorrect';
ERROR_DEVICE_NOT_PARTITIONED : erreur:='Error, Partition information not found';
ERROR_UNABLE_TO_LOCK_MEDIA : erreur:='Error, An attempt to lock the ejection mechanism failed';
ERROR_UNABLE_TO_UNLOAD_MEDIA : erreur:='Error, An attempt to unload the media failed';
ERROR_MEDIA_CHANGED : erreur:='Error, The tape in the drive has been replaced.' +
'This tape drive may be type QIC which is not supported.';
ERROR_BUS_RESET : erreur:='Error, A reset condition was detected on the bus';
ERROR_NO_MEDIA_IN_DRIVE : erreur:='There is no media in the drive';
ERROR_BAD_DEVICE : erreur:='ERROR_BAD_DEVICE';
ERROR_BAD_NETPATH : erreur:='ERROR_BAD_NETPATH';
ERROR_BAD_DEV_TYPE : erreur:=' ERROR_BAD_DEV_TYPE';
ERROR_REQ_NOT_ACCEP : erreur:='ERROR_REQ_NOT_ACCEP';
end;
if Result=False then begin
Form1.Memo1.Lines.Add(erreur+'('+intToStr(Resultat)+')');
ShowMessage(erreur+'('+intToStr(Resultat)+')');
end;
End; |
Partager