Jump to content
Sign in to follow this  
limelect

webcam settings

Recommended Posts

I just want to open webcam setting with Delphi

window 7

just code plz

Screenshot - 02_12_2023 , 17_59_03.jpg

Edited by limelect

Share this post


Link to post

I found this project

https://github.com/jpalbert/webcam-settings-dialog-windows

I changed the bat to

chcp 65001 > nul
ffmpeg -f dshow -show_video_device_dialog true -i video="Integrated Camera"
and it works

however, doing the same with Delphi does not work

as I have GetDosOutput that does not do the job

Any idea how to do this with Delphi?

GetDosOutput works when I read info from a program

I tried to delete the repeat section

Any other Dos reading?

 

procedure TForm1.GetDosOutput(CommandLine: string);
const
  ReadBuffer = 32768; // 32kb buffer

var
  SA: TSecurityAttributes;
  SI: TStartupInfo;
  PI: TProcessInformation;
  StdOutPipeRead, StdOutPipeWrite: THandle;
  WasOK: Boolean;
  Buffer: array[0..ReadBuffer] of AnsiChar;
  BytesRead: Cardinal;
  Handle: Boolean;
  Apprunning: DWord;
  //  T: Ttime;
  TotalBytesRead,
    ExitCode: DWORD;

  BytesLeftThisMessage,
    TotalBytesAvail: integer;
  par_s: string;
begin
  //  Result := '';
  Application.ProcessMessages;

  with SA do
  begin
    nLength := SizeOf(SA);
    bInheritHandle := True;
    lpSecurityDescriptor := nil;
  end;
  CreatePipe(StdOutPipeRead, StdOutPipeWrite, @SA, 0);
  try
    with SI do
    begin
      FillChar(SI, SizeOf(SI), 0);
      cb := SizeOf(SI);
      dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
      wShowWindow := SW_HIDE;
      hStdInput := GetStdHandle(STD_INPUT_HANDLE);
      // StdOutPipeRead; don't redirect stdin
      hStdOutput := StdOutPipeWrite;
      hStdError := StdOutPipeWrite;
    end;
    try
      UniqueString(CommandLine);
      Handle := CreateProcess(nil,
        PChar(CommandLine),
        @SA,
        @SA,
        true,
        (CREATE_NEW_CONSOLE) or (REALTIME_PRIORITY_CLASS),
        //   NORMAL_PRIORITY_CLASS,
        nil,
        //    PChar(WorkDir),
        nil,
        sI,
        PI);
    except
    end;
    CloseHandle(StdOutPipeWrite);
         begin
      repeat
        Apprunning := WaitForSingleObject(PI.hProcess, 100);
        Application.ProcessMessages;
      until (Apprunning <> WAIT_TIMEOUT) { or (stop2)};
      repeat
        if PeekNamedPipe(StdOutPipeRead, @Buffer[0], ReadBuffer, @BytesRead,
          @TotalBytesAvail, @BytesLeftThisMessage) then
          if BytesRead > 0 then
          begin
            //      ReadFile(ReadPipe,Buffer[0], ReadBuffer,BytesRead,nil) ;
            WasOK := ReadFile(StdOutPipeRead, Buffer[0], BytesRead, BytesRead,
              nil);
            if BytesRead > 0 then
            begin

              Buffer[BytesRead] := #0;
              OemToAnsi(Buffer, Buffer);
              par_s := StrPas(Buffer);
              if par_s <> '' then
                Memo1.Lines.Add(par_s);
            end;
          end;
      until (BytesRead > 0) {or (stop2)}; // < ReadBuffer) ;

    end;
  finally
    // stop2 := false;
    CloseHandle(PI.hThread);
    CloseHandle(PI.hProcess);
    CloseHandle(StdOutPipeRead);
    //    GoToFirstLine;
  end;

end;
 

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×