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 8803127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:15:41+00:00 2026-06-14T01:15:41+00:00

I’m getting error code 2, Can’t find the file. But i’ve tried with full

  • 0

I’m getting error code 2, Can’t find the file. But i’ve tried with full path and without.
I’ve had no luck getting the process to start and i don’t know what my mistake is, can somebody point it out?

This is the full code:

#include "stdafx.h"
#include <map>
#include <psapi.h>
#include "shlwapi.h"

#define ERROR_FILE_NOT_FOUND = 2;

void Debug(char* path[])
{
    STARTUPINFO si;
    PROCESS_INFORMATION pi;

    ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) );

    char* p = path[0];
    char* args = path[1];

    int dwProcess = CreateProcess((LPCWSTR)p, (LPWSTR)args, NULL, NULL, false, DEBUG_ONLY_THIS_PROCESS, NULL, NULL, &si, &pi);

    if (!dwProcess)
    {
        DWORD dwLastErrorCode = GetLastError();
        printf("Error: %d", dwLastErrorCode);
    }

    DEBUG_EVENT debug_event = {0};
    DWORD dwContinueStatus  = DBG_CONTINUE;
    DWORD dwResume          = DBG_EXCEPTION_HANDLED;

    while (!WaitForDebugEvent(&debug_event, INFINITE))
    {
        switch(debug_event.dwDebugEventCode)
        {
            case EXCEPTION_DEBUG_EVENT:
            {
                EXCEPTION_DEBUG_INFO& exception = debug_event.u.Exception;

                if (exception.ExceptionRecord.ExceptionCode == 0x0EEDFADE && exception.dwFirstChance)
                    dwContinueStatus = dwResume;
            }
        }
        ContinueDebugEvent(debug_event.dwProcessId, debug_event.dwThreadId, dwContinueStatus);
    }
}

int main(char* argv[])
{
    char* p[2] = { "Notepad.exe", "args" };
    Debug(p);

    return 0;
}

Any help appreciated.

  • 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-14T01:15:42+00:00Added an answer on June 14, 2026 at 1:15 am
    int dwProcess = CreateProcess((LPCWSTR)p, (LPWSTR)args,
    

    ↑ Don’t cast char* to wchar_t*.

    Remove all C casts and be much happier. 🙂

    As a practical matter, use wide strings (wchar_t-based) for dealing with the Windows API.

    A simple way to get wide character program arguments with Visual C++ (although it’s specific to this compiler) is to use wmain instead of standard main.


    Amendment I forgot this is SO. So what actually happens when you cast a char* to wchar_t*?

    Well in Windows each wchar_t is 2 bytes. This means that each pair of successive char values in your strings will be treated as one wchar_t value, if the thing doesn’t crash. It might crash because the null-termination of a wide string is 2 zero bytes, while your char strings only guarantee a single zero byte, so from the point of view of the CreateProcess code your strings may continue indefinitely…

    In short, don’t cast.

    Each cast says to the compiler, “Shut up, compiler, cause I really do understand what I’m doing, I’m not doing this by mistake!”

    And if one does not actually know what one’s about, then the effect is to silence the tool that keep on trying to help you avoid catastrophe.

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

Sidebar

Related Questions

I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I have just tried to save a simple *.rtf file with some websites and
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

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.