Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ConvertToUNCPath(AMappedDrive: string) : string;
- var
- lRemoteString : array[0..255] of char;
- lpRemote : PChar;
- lStringLen : Cardinal;
- begin
- lpRemote := @lRemoteString;
- lStringLen := 255;
- If WNetGetConnection(Pchar(ExtractFileDrive(AMappedDrive)) ,
- lpRemote,
- lStringLen) = NO_ERROR Then
- Result := lRemoteString
- else
- Result := ''; // No mapping found
- end;
- function TDataModuleData.OpenGDBDatabase(AGDBName: string) : Boolean;
- var
- lDlgLogin: TFrmLogin;
- p : Integer;
- lUNC,
- lErrMsg : String;
- begin
- Result := False;
- with FDConnection do // TFDConnection
- begin
- Close;
- TxOptions.Isolation := xiDirtyRead;
- p := Pos(':',AGDBName);
- if p = 2 then
- begin
- lUNC := ConvertToUNCPath(Copy(AGDBName,1,2));
- if lUNC <> '' then
- begin
- lUNC := Copy(lUNC,3);
- p := pos('',lUNC);
- AGDBName := Copy(lUNC,p) + Copy(AGDBName,3);
- lUNC := copy(lUNC,1,p-1);
- end;
- end;
- DriverName := S_FD_IBId;
- Params.Database := AGDBName;
- if lUNC <> '' then
- Params.Add('Server=' + lUNC)
- else
- Params.Add('Server=localhost'); // Not strictly necessary
- Params.UserName := 'SYSDBA';
- Params.Password := 'masterkey';
- try
- Open;
- Result := Connected;
- except
- on E:Exception do
- begin
- lErrMsg := LowerCase(E.Message);
- end;
- end;
- end;
- end;
Add Comment
Please, Sign In to add comment