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

  • SEARCH
  • Home
  • 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 8096977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:36:43+00:00 2026-06-05T21:36:43+00:00

I have a function, that reads a registry key, get a path for a

  • 0

I have a function, that reads a registry key, get a path for a program there, and call a CreateProcessA with this path as second parameter. Debugging the application, it fails saying that the file was not found.

a) yes, the file exists
b) yes, i have access to execute the file

Question: The function that actually reads the reg key and give the path to CreateProcessA, doesn’t escape the path: it means, CreateProcessA receives a string like “C:\Program Files\prog.exe” and not like “C:\\Program Files\\prog.exe”. Is that the problem? Does exist any Windows Function to escape all backslashes automatically?

  • 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-06-05T21:36:45+00:00Added an answer on June 5, 2026 at 9:36 pm

    Common errors include not specifying the path to the executable as the first argument to CreateProcess, and not quoting the path to the executable in the second argument

    CreateProcess( <exe path goes here> , <quoted exe path plus parameters goes here>, ... );
    

    Like so:

    std::wstring executable_string(_T("c:\\program files\\myprogram\\executable.exe"));
    std::wstring parameters(_T("-param1 -param2"));
    
    wchar_t path[MAX_PATH+3];
    PathCanonicalize(path, executable_string.c_str());
    path[sizeof(path)/sizeof(path[0]) - 1] = _T('\0');
    
    // Make sure that the exe is specified without quotes.
    PathUnquoteSpaces(path);
    const std::wstring exe = path;
    
    // Make sure that the cmdLine specifies the path to the executable using
    // quotes if necessary.
    PathQuoteSpaces(path);
    std::wstring cmdLine = path + std::wstring(_T(" ")) + parameters;
    
    BOOL res = CreateProcess(
                     exe.c_str(),
                     const_cast<wchar_t *>(cmdLine.c_str()),
                     ...);
    

    I just copied and adapted some, so there might be some errors in the above, but the idea is there. Make sure to use path without quotes in the first parameter and path with quotes in the second and you should be fine.

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

Sidebar

Related Questions

I have this function on my controller (Im using CodeIgniter) that reads the database,
I have a function that reads a bunch of path-values (8 or 9 of
I have a function that reads a formatted file. It looks like this: 1;Name_of_the_author;The
I have a function that reads from the console using readPassword(). This function is
I have an example function below that reads in a date as a string
I have a function that reads a rom file into memory and automatically allocates
I have a program that reads arbitrary data from a file system and outputs
I have a function that counts registry items and added a new option to
I have a function that essentially reads values in from a vector of doubles,
I have a c function (dbread) that reads 'fields' from a 'database'. Most of

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.