GSM Shop GSM Shop
GSM-Forum  

Welcome to the GSM-Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features.
Only registered members may post questions, contact other members or search our database of over 8 million posts.

Registration is fast, simple and absolutely free so please - Click to REGISTER!

If you have any problems with the registration process or your account login, please contact contact us .

Go Back   GSM-Forum > Other Gsm/Mobile Related Forums > GSM Programming & Reverse Engineering


GSM Programming & Reverse Engineering Here you can post all Kind of GSM Programming and Reverse Engineering tools and Secrets.

Reply
 
LinkBack Thread Tools Display Modes
Old 07-20-2011, 10:18   #1 (permalink)
Freak Poster
 
Join Date: Jul 2011
Location: Australia/Melbourne
Posts: 122
Member: 1610809
Status: Offline
Sonork: 100.1616347
Thanks Meter: 23
Question coment Bat File insert to memo.. Help


(DHELPHI)


any can help me?
how BAT file from the command inserted to the memo and then call the cmd to run it
  Reply With Quote
Old 07-20-2011, 10:35   #2 (permalink)
Product Manager
 
orbita's Avatar
 
Join Date: Apr 2002
Location: nckDongle
Posts: 13,325
Member: 11170
Status: Offline
Sonork: 1603694
Thanks Meter: 6,944
you must use pipes for this, and load console application in stream.
See microsoft API, all is good documented.
  Reply With Quote
The Following User Says Thank You to orbita For This Useful Post:
Old 07-20-2011, 14:43   #3 (permalink)
Insane Poster
 
Join Date: May 2008
Location: Poland ;)
Age: 38
Posts: 69
Member: 776944
Status: Offline
Thanks Meter: 26
Using pipes to catch console output. Here's an example:

How to catch console output - Delphi Pages Forums
  Reply With Quote
The Following User Says Thank You to McManiek For This Useful Post:
Old 07-20-2011, 21:37   #4 (permalink)
No Life Poster
 
dzunlocker's Avatar
 
Join Date: Aug 2004
Location: With old & new friends
Age: 49
Posts: 691
Member: 79640
Status: Offline
Sonork: 1577251
Thanks Meter: 238
look for ShellExecute API
  Reply With Quote
The Following User Says Thank You to dzunlocker For This Useful Post:
Old 07-29-2011, 07:39   #5 (permalink)
Freak Poster
 
Join Date: Jul 2011
Location: Australia/Melbourne
Posts: 122
Member: 1610809
Status: Offline
Sonork: 100.1616347
Thanks Meter: 23
function RunProg(Cmd, WorkDir: String): string;

Form1.Memo1.Tex:=('Javaloader -u load OS\Bla_Bla.cod'+
'Bla_bla!.Cod','C:\');
what this true ??
what CMD runprog to one line ?
  Reply With Quote
Old 07-30-2011, 11:13   #6 (permalink)
Product Manager
 
orbita's Avatar
 
Join Date: Apr 2002
Location: nckDongle
Posts: 13,325
Member: 11170
Status: Offline
Sonork: 1603694
Thanks Meter: 6,944
Code:
procedure TForm1.RunDosInMemo(DosApp:String;AMemo:TMemo) ;
  const
     ReadBuffer = 1048576;
  var
   Security : TSecurityAttributes;
   ReadPipe,WritePipe : THandle;
   start : TStartUpInfo;
   ProcessInfo : TProcessInformation;
   Buffer : Pchar;
   BytesRead : DWord;
   Apprunning : DWord;
  begin
   With Security do begin
    nlength := SizeOf(TSecurityAttributes) ;
    binherithandle := true;
    lpsecuritydescriptor := nil;
   end;
   if Createpipe (ReadPipe, WritePipe,
                  @Security, 0) then begin
    Buffer := AllocMem(ReadBuffer + 1) ;
    FillChar(Start,Sizeof(Start),#0) ;
    start.cb := SizeOf(start) ;
    start.hStdOutput := WritePipe;
    start.hStdInput := ReadPipe;
    start.dwFlags := STARTF_USESTDHANDLES +
                         STARTF_USESHOWWINDOW;
    start.wShowWindow := SW_HIDE;

    if CreateProcess(nil,
           PChar(DosApp),
           @Security,
           @Security,
           true,
           NORMAL_PRIORITY_CLASS,
           nil,
           nil,
           start,
           ProcessInfo)
    then
    begin
     repeat
      Apprunning := WaitForSingleObject
                   (ProcessInfo.hProcess,100) ;
      Application.ProcessMessages;
     until (Apprunning <> WAIT_TIMEOUT) ;
      Repeat
        BytesRead := 0;
        ReadFile(ReadPipe,Buffer[0],
ReadBuffer,BytesRead,nil) ;
        Buffer[BytesRead]:= #0;
        OemToAnsi(Buffer,Buffer) ;
        AMemo.Text := AMemo.text + String(Buffer) ;
      until (BytesRead < ReadBuffer) ;
   end;
   FreeMem(Buffer) ;
   CloseHandle(ProcessInfo.hProcess) ;
   CloseHandle(ProcessInfo.hThread) ;
   CloseHandle(ReadPipe) ;
   CloseHandle(WritePipe) ;
   end;
  end;


function TForm1.RunCaptured(const _dirName, _exeName, _cmdLine: string): Boolean;
var
  start: TStartupInfo;
  procInfo: TProcessInformation;
  tmpName: string;
  tmp: Windows.THandle;
  tmpSec: TSecurityAttributes;
  res: TStringList;
  return: Cardinal;
  i:integer;
begin
  Result := False;
  try
    { Setze ein Temporäres File }
    { Set a temporary file }
    tmpName := 'Test.tmp';
    FillChar(tmpSec, SizeOf(tmpSec), #0);
    tmpSec.nLength := SizeOf(tmpSec);
    tmpSec.bInheritHandle := True;
    tmp := Windows.CreateFile(PChar(tmpName),
           Generic_Write, File_Share_Write,
           @tmpSec, Create_Always, File_Attribute_Normal, 0);
    try
      FillChar(start, SizeOf(start), #0);
      start.cb          := SizeOf(start);
      start.hStdOutput  := tmp;
      start.dwFlags     := StartF_UseStdHandles or StartF_UseShowWindow;
      start.wShowWindow := SW_HIDE;///SW_Minimize;
      { Starte das Programm }
      { Start the program }
      if CreateProcess(nil, PChar(_exeName + ' ' + _cmdLine), nil, nil, True,
                       0, nil, PChar(_dirName), start, procInfo) then
      begin
        SetPriorityClass(procInfo.hProcess, Idle_Priority_Class);
        WaitForSingleObject(procInfo.hProcess, Infinite);
        GetExitCodeProcess(procInfo.hProcess, return);
        Result := (return = 0);
        CloseHandle(procInfo.hThread);
        CloseHandle(procInfo.hProcess);
        Windows.CloseHandle(tmp);
        { Die Ausgaben hinzufügen }
        { Add the output }
        res := TStringList.Create;
        try
          res.LoadFromFile(tmpName);
          for i:=0 to res.Count-1 do
          If pos('Uploading RAM Image',res[i])=0 then
          Memo1.Lines.Add(res[i]);
        finally
          res.Free;
        end;
        Windows.DeleteFile(PChar(tmpName));
      end
      else
      begin
        Application.MessageBox(PChar(SysErrorMessage(GetLastError())),
          'RunCaptured Error', MB_OK);
      end;
    except
      Windows.CloseHandle(tmp);
      Windows.DeleteFile(PChar(tmpName));
      raise;
    end;
  finally
    end;
    CloseThread(hThread);
end;

here is 2 function for your needs , chose one best for you.
  Reply With Quote
The Following User Says Thank You to orbita For This Useful Post:
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP!!! BACKGROUND SCREEN LOGO Michael Go Nokia Legacy Phones ( DCT-1 ,2 ,3 ,L ) 8 11-23-2017 08:11
news headlines to gsm phone mos Nokia Legacy Phones ( DCT-1 ,2 ,3 ,L ) 7 05-22-2016 11:42
How to add a language in 51xx/61xx tati Nokia Legacy Phones ( DCT-1 ,2 ,3 ,L ) 8 05-21-2013 19:20
How to upload a new firmware... Brand Nokia Legacy Phones ( DCT-1 ,2 ,3 ,L ) 8 06-08-2012 18:29
Help with 6110 paulomt1 Nokia Legacy Phones ( DCT-1 ,2 ,3 ,L ) 2 05-25-2009 16:29

 



All times are GMT +1. The time now is 19:03.



Powered by Searchlight © 2024 Axivo Inc.
vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
- GSM Hosting Ltd. - 1999-2023 -
Page generated in 0.18359 seconds with 9 queries

SEO by vBSEO