Question

I tried to create an installer to check the current transmission control protocol connections on windows64 machine. Is it possible to create?

am going to use command line using extern. if I give ls -lf it will returns all the files which are currently running on

[code]
const
GetFileExInfoStandard = $0;

type 
FILETIME = record 
LowDateTime:  DWORD; 
HighDateTime: DWORD; 
end; 
WIN32_FILE_ATTRIBUTE_DATA = record 
FileAttributes: DWORD; 
CreationTime:   FILETIME; 
LastAccessTime: FILETIME; 
LastWriteTime:  FILETIME; 
  FileSizeHigh:   DWORD; 
  FileSizeLow:    DWORD; 
end;

SYSTEMTIME = record 
  Year:         WORD; 
  Month:        WORD; 
  DayOfWeek:    WORD; 
  Day:          WORD; 
  Hour:         WORD; 
  Minute:       WORD; 
  Second:       WORD; 
  Milliseconds: WORD; 
end;   

function GetFileAttributesEx ( 
  FileName:             string;
  InfoLevelId:          DWORD;
  var FileInformation:  WIN32_FILE_ATTRIBUTE_DATA
  ): Boolean; 
external 'GetFileAttributesExA@kernel32.dll stdcall'; 

function FileTimeToSystemTime(
  FileTime:           FILETIME;
  var SystemTime:     SYSTEMTIME
  ): Boolean; 
external 'FileTimeToSystemTime@kernel32.dll stdcall';
var
TmpfileName: String;
i,j,ResultCode:integer;
ExecStdout,processes:Tarrayofstring;
Page:TInputOptionWizardPage;

procedure initializeWizard;
begin
  TmpFileName := ExpandConstant('{tmp}') + '\processes.txt';
  Exec('cmd.exe','/C netstat > "' + TmpFileName + '"',
  '',SW_HIDE,ewWaitUntilTerminated, ResultCode);
  Page := CreateInputOptionPage(wpWelcome,
  'Current Running processes on your      computer',
  'Displays All Running  processes on this machine, selecte any process
   to terminate','Seleet Any one from the list, Click on next'+#13+
  'Note: Do not select System processes this may cause damage to your machine..'
  ,  True, True); 
  end;

 function NextButtonClick(CurPageID: Integer): Boolean;
 begin
 if CurPageID = wpwelcome then
 begin
 if LoadStringsFromFile(TmpFileName, ExecStdout) then
      begin
       for i:=3 to GetArrayLength(ExecStdout)-1 do
        begin
         setarraylength(processes,i-2)
          processes[i-3]:='';
         for j:=1 to length(Execstdout[i]) do
            begin  
             if not ((Execstdout[i][j]=' ') and (Execstdout[i][j+1]=' ')) then
               begin
                processes[i-3]:=processes[i-3]+execstdout[i][j];
               end;
               if ((Execstdout[i][j]=' ') and (Execstdout[i][j+1]=' ')) then
               j:=length(Execstdout[i]);

            end;
            page.add(processes[i-3]);
         end;
      end;

 Result:=true;
 end;
 if CurPageID = page.id then
 begin
 result:=true;
 end;
  if CurPageID = wpReady then
 Result:=true;

end;

Was it helpful?

Solution

This code is perfectly working but it may take half minute to show the result.

[Code]

function NextButtonClick(CurPage: Integer): Boolean;
var
    TmpFileName, ExecStdout: string;
    ResultCode: integer;
begin
   if CurPage = wpWelcome then begin
   TmpFileName := ExpandConstant('{tmp}') + '\ipconfig_results.txt';
   Exec('cmd.exe', '/C netstat > "' + TmpFileName + '"', '', SW_HIDE,
          ewWaitUntilTerminated, ResultCode);
if LoadStringFromFile(TmpFileName, ExecStdout) then begin

       MsgBox(ExecStdout, mbInformation, MB_OK);
      // do something with contents of file...
     end;
   DeleteFile(TmpFileName);
   end;
   Result := True;
 end;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top