Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4115726
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:37:09+00:00 2026-05-20T22:37:09+00:00

How do I send a string to a process I have opened with the

  • 0

How do I send a string to a process I have opened with the help of createprocess?

I’ve written something like this with the help of what I’ve found here in Stackoverflow:

    var
    StartUpInfo:TStartUpInfo;
    ProcessInfo: TProcessInformation;
    Creationflags: Cardinal;

    FillChar(StartUpInfo, sizeOf(TStartupinfo),0);
    StartUpInfo.cb := SizeOf(StartupInfo);
    Creationflags := NORMAL_PRIORITY_CLASS;

    if Createprocess(nil, Pchar('c:\program files\adobe\reader 9.0\reader\acrord32.exe'
    + ' ' + '/h /O /N /T "c:\ps\test2.pdf" "Generic printer"'),nil, nil,False, 
    creationflags, nil, 0 , StartUpInfo ,  ProcessInfo) then

    begin
      WaitForSingleObject(ProcessInfo.HProcess, infinite);
         begin
           //write some information into the process (a window that opens in 
           //acrobatreader) and then I want to press the enter button            
         end;
      CloseHandle(processinfo.hProcess);

    end;

So what I want is to write a line when the process is finished (right after waitforsingleobject) and then press the “enter” button, and finally close the process when it is finished. Does Anyone know how to interact with external processes? I am a total newbie when it comes to programming.

Best Regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:37:10+00:00Added an answer on May 20, 2026 at 10:37 pm

    You appear to be trying programmatically to get Acrobat Read to print your document. Your problem is that you can’t persuade it to do so without it asking for user interaction.

    Your current code cannot work because you are waiting for the process to terminate. Once you start with a simple call to WaitForSingleObject, none of your code can run until the process terminates. You do not get an opportunity for you code to click that button.

    So what you need to do is to use a different waiting strategy. Since this appears to be a fairly crude hack, I’ll suggest something I would not normally suggest: polling. Instead of waiting with an infinite timeout you should wait, in a loop, with a timeout value of, say, 250ms. Each time the wait terminates you check to see whether the process has terminated or alternatively whether wait timed out.

    When the wait has timed out, you have an opportunity to look for the dialog window that you want to find. You should be able to locate it with FindWindowEx(). You can discover its class name using Spy++. Once you have found the dialog window then you need to locate the window handle for the edit control and the button you want to click: EnumChildWindows() should do the trick.

    Once you have the handles of the controls you want to manipulate you need to work out how to manipulate them. If you are lucky you can send the string with a call to SetWindowText if it is an EDIT control or similar. Otherwise you may have to fake the key-presses or maybe send it a WM_PASTE. The button may be more troublesome. Clicking it involves sending a WM_COMMAND to the buttons parent. Again Spy++ can show you what messages are sent when you click a button.

    Of course, you may not find your window when you call FindWindowEx() because it hasn’t shown yet. When that happens you go round the loop again with a call to WaitForSingleObject().

    Finally, a much better way to handle this would be to use a software library dedicated to printing PDF!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code like this : PersistenceManager pm=PMF.get().getPersistenceManager(); String query=select from +PayPal_Message.class.getName()+ where
In Javascript I can send XML string to JSP server (XmlAction.jsp): Javascript Code: var
I have the following problem, from c++ I send huge string[] to java. huge
I have found this site very useful for all my previously faced problems, However
I have setup a process in my User model to send a bunch of
I have 5 buttons that are going to call this popup function to send
I can only send string or numeric values,how to send an array?
I want to send String from C# to Jave I do it in C#
I want to send base64 string through ajax I encoded it through JavaScript function
I need to send a string as parameter in UIButton selector. Taking global string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.