- Details
- Written by: Stanko Milosev
- Category: Delphi
- Hits: 4749
You need to access computer which is not in a domain?
No problem
Here is the code:
var token: Cardinal;
dwResult: DWORD;
nr: TNETRESOURCE;
sl: TStringList;
begin
nr.dwType := RESOURCETYPE_DISK;
nr.lpProvider := nil;
nr.lpLocalName := nil;
nr.lpRemoteName := '\\computername\sharedfolder';
//\\computername\sharedfolder\ will not work - just with ExcludeTrailingPathDelimiter
\\also will not work \\computername\d$\folder\ - we need just \\computername\d$
dwResult := WNetAddConnection2(nr, 'password', 'user', 0); //watchout username and pass are on strange positions, at least for me
if (dwResult = NO_ERROR) or (dwResult = ERROR_ALREADY_ASSIGNED) or (dwResult = ERROR_SESSION_CREDENTIAL_CONFLICT) then
begin
sl := TStringList.Create;
sl.LoadFromFile('\\computername\sharedfolder\file.txt');
ShowMessage(sl.Strings[1]);
FreeAndNil(sl);
end;
end;
Taken from here.
- Details
- Written by: Stanko Milosev
- Category: Delphi
- Hits: 4723
I you receive compiler warning like:
[DCC Warning] uGC88.pas(24): W1010 Method 'Txt2Db' hides virtual method of base type 'TGC88'
Then just use reintroduce keyword.
Like:
TGC88 = class
procedure Txt2Db;virtual;abstract;
end;
type
TGC88Pdf = class(TGC88)
procedure Txt2Db;reintroduce;
end;
- Details
- Written by: Stanko Milosev
- Category: Delphi
- Hits: 4474
If you need something to do before build or after build in Project->Options go on Build events.
In my case I needed to compile resource file to add one exeso for sure is always there (mostly because of CVS and other developers).
Syntax is something like this:
call "res\pdftotext.bat"
if %errorlevel% neq 0 exit %errorlevel%