• 0

Running an .exe programmatically


Question

8 answers to this question

Recommended Posts

  • 0

could use the WinExec API.

  Quote
The WinExec function runs the specified application.

This function is provided for compatibility with earlier versions of Windows. For Win32-based applications, use the CreateProcess function.

UINT WinExec(

    LPCSTR lpCmdLine, // address of command line

    UINT uCmdShow  // window style for new application

  );

Parameters

lpCmdLine

Points to a null-terminated character string that contains the command line (filename plus optional parameters) for the application to be executed. If the name of the executable file in the lpCmdLine parameter does not contain a directory path, Windows searches for the executable file in this sequence:

1. The directory from which the application loaded.

2. The current directory.

3. The Windows system directory. The GetSystemDirectory function retrieves the path of this directory.

4. The Windows directory. The GetWindowsDirectory function retrieves the path of this directory.

5. The directories listed in the PATH environment variable.

uCmdShow

Specifies how a Windows-based application window is to be shown and is used to supply the wShowWindow member of the STARTUPINFO parameter to the CreateProcess function. For a list of the acceptable values, see the description of the nCmdShow parameter of the ShowWindow function. For a non-Windows - based application, the PIF file, if any, for the application determines the window state.

Return Values

If the function succeeds, the return value is greater than 31.

If the function fails, the return value is one of the following error values:

Value Meaning

0 The system is out of memory or resources.

ERROR_BAD_FORMAT The .EXE file is invalid (non-Win32 .EXE or error in .EXE image).

ERROR_FILE_NOT_FOUND The specified file was not found.

ERROR_PATH_NOT_FOUND The specified path was not found.

Remarks

Win32-based applications should use the CreateProcess function rather than this function. The WinExec function exists in Win32 to provide compatibility with earlier versions of Windows. For more information about how the WinExec function is implemented, see the Remarks section of the LoadModule function.

In Win32, the WinExec function returns when the started process calls the GetMessage function or a time-out limit is reached. To avoid waiting for the time out delay, call the GetMessage function as soon as possible in any process started by a call to WinExec.

  Quote
This function is provided for compatibility with earlier versions of Windows. For Win32-based applications, use the CreateProcess function.

ho hum :) never used that before. but winexec works fine for me :)

Edited by _tux_
  • 0
  bangbang023 said:
Um it does matter because VB won't accept C++ code, Java won't accept BASIC, and so on and so forth.

*sigh* Well yes obviously it would have to be translated. But no, the language of the example doesn't matter, because it's a Windows API function. And if the poster can't figure out how to call an API function in his/her programming language of choice, then what language the example is in is probably even LESS relevant; programming lessons would seem to be a bigger priority.

  Quote
It could very well be Java... So it kind of does matter...

True, but then the poster didn't specify, and hasn't come back to specify, so really, s/he'll just have to take whatever is offered.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • This is an example of why it is so difficult to have a conversation with conservatives - they refuse to operate in good faith. You say "Those are not rights. Those were special treatments that were taken away that non-trans whatever didn't get." Which means you either failed to read any of the links I provided or you are lying. The very first link is about how the U.S. Military is firing trans people out of the military because they are trans and denying them retirement benefits. What other groups does the military treat this way that would support your assertion that they had been treated as special previously? Does the miliary routinely fire large numbers of its members and deny them retirement and was heretofore not doing that to trans people? I fail to see the logic in your argument.
    • Dell's Tower Plus Windows 11 desktop brings good all round performance at a big discount by Paul Hill Are you looking for a powerful tower desktop PC? If so, Dell’s Tower Plus EBT2250 is available for $1,099.99 right now, discounted down 25% from its typical price of $1,460.64, making it its lowest price in 30 days, and indeed, of all time (purchase link towards the bottom of the article). It’s powered by an Intel Core Ultra 7 265 processor and an NVIDIA GeForce RTX 4060 GPU. It also features an NPU which achieves 13 TOPs, but it is not a Copilot+ PC which demand 40 TOPs. Nonetheless, Dell also claimed a 26% performance boost in multi-core applications compared to the previous generation XPS Desktop. It also comes with a 1TB NVMe SSD for speedy boots and app launches and there is 1x 16GB DDR5-5200 RAM which should help to cut through all of your tasks, though, it may not be enough for very demanding tasks. Dell has made this tower PC with upgrades in mind with available memory, storage, and expansion slots. It also features a new thermal design with 120mm fan, and the company claims this makes it up to 22% quieter while maintaining cooling performance. Here's more about the expansion options: The system supports dual 4K monitors through an HDMI 2.0 port and a Thunderbolt 4 Type-C port. It also has a built-in media card reader for quick import of RAW images. Another nice feature with this tower is that it’s equipped with Wi-Fi 7, which promises “4.8x faster throughput, lower latency and greater capacity” for seamless online experiences. This Dell comes with Windows 11 Home and 6-months of Dell Migrate to help users move files and settings to their new computer. If you are interested in this deal, check out the buying link below. Dell Tower Plus EBT2250: $1,099.99 (Amazon US) / MSRP $1,460.64 This Amazon deal is US-specific and not available in other regions unless specified. If you don't like it or want to look at more options, check out the Amazon US deals page here. Get Prime (SNAP), Prime Video, Audible Plus or Kindle / Music Unlimited. Free for 30 days. As an Amazon Associate, we earn from qualifying purchases.
    • The first stars in the universe may have been much smaller than we thought, new research hints — possibly explaining why it's so hard to find evidence they ever existed. According to the new research, the earliest generation of stars had a difficult history. These stars came to be in a violent environment: inside a huge gas cloud whipping with supersonic-speed turbulence at velocities five times the speed of sound (as measured in Earth's atmosphere). A simulation underpinning the new research also showed gases clustering into lumps and bumps that appeared to herald a coming starbirth. The cloud broke apart, creating pieces from which clusters of stars seemed poised to emerge. One gas cloud eventually settled into the right conditions to form a star eight times the mass of our sun — much smaller than the 100-solar-mass behemoths researchers previously imagined in our early universe. "With the presence of supersonic turbulence, the cloud becomes fragmented into multiple smaller clumps, leading to the formation of several less massive stars instead," principal researcher Ke-Jung Chen, a research fellow at the Academia Sinica Institute of Astronomy and Astrophysics in Taiwan https://www.livescience.com/space/astronomy/scientists-may-finally-know-why-the-first-stars-in-the-universe-left-no-trace  
  • Recent Achievements

    • One Month Later
      Jaclidio hoy earned a badge
      One Month Later
    • Week One Done
      Yawdee earned a badge
      Week One Done
    • Week One Done
      eugwalker earned a badge
      Week One Done
    • First Post
      Ben Gross earned a badge
      First Post
    • One Month Later
      chiptuning earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      640
    2. 2
      +FloatingFatMan
      183
    3. 3
      ATLien_0
      146
    4. 4
      Xenon
      123
    5. 5
      wakjak
      107
  • Tell a friend

    Love Neowin? Tell a friend!