looking for delphi copen source of a similar program

boycoder
boycoder used Ask the Experts™
on
http://www.nirsoft.net/utils/web_browser_password.html

and

http://www.nirsoft.net/utils/mailpv.html

Need to add these into my own program to nearly complete my system admin control center.
Anything would be great I have no experiance in decryping at all.
These two are perfect for me
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Freelance Project Manager
Top Expert 2010
Commented:
Both application represent certainly a huge amount of research and work.
They both require extensive knowledge about a good number of web/mail applications.
I doubt very much that anyone here do have that knowledge, so I guess you have 2 options
a) "include" both applications in yours by calling the exe as a command line tool and process the resulting files
b) ask the author to provide those app functionalities as a DLL

I think a) is the best, as the author did think about a command line mode. That is not overly too complex to call an exe and get the output as a file, from a Delphi application. If that is your wish, I provide here a unit  to do that

Call like this :
RunDosApp('WebBrowserPassView.exe /scomma PASSWORD.LST', '', True );
and open the PASSWORD.LST file to get password list

Tell us if you need help loading a comma delimited text file into a TListView (for example)

PS : I noticed after a second look that you don't really need to capture the console output as the list is saved to a file. But that has at least the interest to make your application wait the end of execution, so that you can immediately after open the result file. In fact, a simple call to CreateProcess and WaitForSingleObject would be enough.

unit BatchUtils;

interface

Uses SysUtils,Classes;

Function RunDosApp(DosApp,CurDir:String;Capture:Boolean=False;Env:TStringList=nil;IncludeParentEnv:Boolean=True):String;

implementation

uses
  Forms, ShellApi,Windows;

function GetAllEnvVars(const Vars: TStrings): Integer;
var
  PEnvVars: PChar;    // pointer to start of environment block
  PEnvEntry: PChar;   // pointer to an env string in block
begin
  // Clear the list
  if Assigned(Vars) then
    Vars.Clear;
  // Get reference to environment block for this process
  PEnvVars := GetEnvironmentStrings;
  if PEnvVars <> nil then
  begin
    // We have a block: extract strings from it
    // Env strings are #0 separated and list ends with #0#0
    PEnvEntry := PEnvVars;
    try
      while PEnvEntry^ <> #0 do
      begin
        if Assigned(Vars) then
          Vars.Add(PEnvEntry);
        Inc(PEnvEntry, StrLen(PEnvEntry) + 1);
      end;
      // Calculate length of block
      Result := (PEnvEntry - PEnvVars) + 1;
    finally
      // Dispose of the memory block
      FreeEnvironmentStrings(PEnvVars);
    end;
  end
  else
    // No block => zero length
    Result := 0;
end;

function CreateEnvBlock(const NewEnv: TStrings;
  const IncludeCurrent: Boolean;
  const Buffer: Pointer;
  const BufSize: Integer): Integer;
var
  EnvVars: TStringList; // env vars in new block
  Idx: Integer;         // loops thru env vars
  PBuf: PChar;          // start env var entry in block
  S:String;
  P:Integer;
begin
  // String list for new environment vars
  EnvVars := TStringList.Create;
  try
    // include current block if required
    if IncludeCurrent then
      GetAllEnvVars(EnvVars);
    // store given environment vars in list
    if Assigned(NewEnv) then for Idx:=0 to NewEnv.Count-1 do
     begin
      S:=NewEnv[Idx];
      P:=Pos('=',S);
      if P>0 Then
       begin
        if EnvVars.Values[Copy(S,1,P-1)]<>'' Then
         begin
          EnvVars.Values[Copy(S,1,P-1)]:=Copy(S,P+1,1000);
         End Else P:=0;
       end;
      if P<=0 Then EnvVars.Add(S);
     end;
    // Calculate size of new environment block
    Result := 0;
    for Idx := 0 to Pred(EnvVars.Count) do
      Inc(Result, Length(EnvVars[Idx]) + 1);
    Inc(Result);
    // Create block if buffer large enough
    if (Buffer <> nil) and (BufSize >= Result) then
    begin
      // new environment blocks are always sorted
      EnvVars.Sorted := True;
      // do the copying
      PBuf := Buffer;
      for Idx := 0 to Pred(EnvVars.Count) do
      begin
        StrPCopy(PBuf, EnvVars[Idx]);
        Inc(PBuf, Length(EnvVars[Idx]) + 1);
      end;
      // terminate block with additional #0
      PBuf^ := #0;
    end;
  finally
    EnvVars.Free;
  end;
end;

Function RunDosApp(DosApp,CurDir:String;Capture:Boolean=False;Env:TStringList=nil;IncludeParentEnv:Boolean=True):String;
const ReadBuffer = 2400;
var
 Security : TSecurityAttributes;
 ReadPipe,WritePipe : THandle;
 start : TStartUpInfo;
 ProcessInfo : TProcessInformation;
 Buffer : Pchar;
 BytesRead : DWord;
 Apprunning : DWord;
 StrL:TStringList;
 BufSize: Integer;         // env block size
 EnvBuffer: PChar;            // env block
begin
 Result:='';
 With Security do
  begin
   nlength := SizeOf(TSecurityAttributes) ;
   binherithandle := true;
   lpsecuritydescriptor := nil;
  end;
 if Not Capture then
  begin
   DosApp:=DosApp+' >RES.TMP';
   DeleteFile(PChar(CurDir+'RES.TMP'));
  end;
 if Createpipe (ReadPipe, WritePipe, @Security, 0) then
  begin
   if Env=nil then EnvBuffer:=nil Else
    begin
     EnvBuffer := StrAlloc(2000);
     BufSize := CreateEnvBlock(Env, IncludeParentEnv, nil, 2000);
     if BufSize>2000 then
      begin
       StrDispose(EnvBuffer);
       EnvBuffer := StrAlloc(BufSize);
       CreateEnvBlock(Env, IncludeParentEnv, EnvBuffer, BufSize);
      end;
    end;
   Buffer := AllocMem(ReadBuffer + 1) ;
   FillChar(Start,Sizeof(Start),#0) ;
   start.cb := SizeOf(start) ;
   if Capture then
    begin
     start.hStdOutput := WritePipe;
     start.hStdError := WritePipe;
     start.dwFlags := STARTF_USESHOWWINDOW+STARTF_USESTDHANDLES ;
    end Else start.dwFlags := STARTF_USESHOWWINDOW;
   start.wShowWindow := SW_HIDE;
   if CreateProcess(nil,
           PChar(DosApp),
           @Security,
           @Security,
           true,
           NORMAL_PRIORITY_CLASS,
           EnvBuffer,
           PChar(CurDir),
           start,
           ProcessInfo) then
    begin
     CloseHandle(WritePipe) ;
     repeat
      Apprunning := WaitForSingleObject(ProcessInfo.hProcess,100) ;
      Application.ProcessMessages;
     until (Apprunning <> WAIT_TIMEOUT) ;
     if Capture then
      begin
       Repeat
        BytesRead := 0;
        ReadFile(ReadPipe,Buffer[0], ReadBuffer,BytesRead,nil) ;
        Buffer[BytesRead]:= #0;
        OemToAnsi(Buffer,Buffer) ;
        Result:=Result+ String(Buffer) ;
       until (BytesRead=0) ;
      end;
    end Else
    begin
      Capture:=True;
      CloseHandle(WritePipe) ;
    end;
   CloseHandle(ReadPipe) ;
   FreeMem(Buffer);
   StrDispose(EnvBuffer);
   CloseHandle(ProcessInfo.hProcess) ;
   CloseHandle(ProcessInfo.hThread) ;
   if Not Capture then
    begin
     StrL:=TStringList.Create;
     try
      StrL.LoadFromFile(CurDir+'RES.TMP');
      Result:=StrL.Text;
     finally
      StrL.Free;
     end;
    end;
  end;
end;

end.

Open in new window

Author

Commented:
superb as always can always count on you!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial