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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:26:52+00:00 2026-05-19T00:26:52+00:00

I am using Windows 7 and I have to run one program in that

  • 0

I am using Windows 7 and I have to run one program in that windows but that program working in Windows XP. This is a Visual C++ program and I am using Visual Studio 2008 for this. When I am running my application, it does not throw any errors, but it does not create a directory in “c:\program files\”. So can anyone help me to create directory and exe file?

This is the code I am using:

char szAppPath[MAX_PATH];
char szFileName[MAX_PATH];
DWORD dwResult;
WIN32_FIND_DATA FindFileData;
HANDLE hFind;

dwResult = ExpandEnvironmentStrings( NULL, szAppPath, MAX_PATH);  // "%ProgramFiles%"


// do same for NSim directory
strcat(szAppPath,"\\NSim");
hFind = FindFirstFile(szAppPath, &FindFileData);

if (hFind == INVALID_HANDLE_VALUE) 
{
    //Directory Does't Exists create New
    if(!CreateDirectory(szAppPath,NULL))  //Throw Error
    {
        MessageBox("Unable to Create N-SIM directory","NSim Installer");
        return ;
    }
} 
else  
{
    //check if is directory or not
    if(!(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) 
    {
        MessageBox("Can't Create N-SIM directory\n Another file with same name exists","NSim Installer");
        return ;
    }

    FindClose(hFind);
}

//***************************************N-SIM Application****************************
strcpy(szFileName, szAppPath);
HRSRC hRes;

if( bRegister == FALSE)
{
    strcat(szFileName,"\\NSim.exe"); //make same name of the Client & Server in program file
    hRes = FindResource(NULL, MAKEINTRESOURCE(IDR_LANSIMSERVER),RT_RCDATA);

    if(flagUpgrade ==0)
    {
        CString trial = installationDate();   //----- Detemine Expiry Date -----

        setRegistry(trial);
    }
}
  • 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-19T00:26:53+00:00Added an answer on May 19, 2026 at 12:26 am

    [edit] I edited the code in the question for readability and removed the commented out code (to see the wood for the trees). It is now obvious that nothing initialises szAppPath before calling strcat(), and calling ExpandEnvironmentStrings with NULL as the first argument is undefined (and certainly useless). Calling strcat() on an unitialised string is not likely to have the desired result. This may be an artefact of not posting the real code, or even of other peoples edits (including mine).


    CreateDirectory sets the system error code on error; if you want to know what went wrong, check it! Any answer you get here will be an educated guess.

    if(!CreateDirectory(szAppPath,NULL))  //Throw Error
    {
        DWORD errorcode = GetLastError(); 
        LPVOID lpMsgBuf;
    
        FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
                      NULL, errorcode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL );
    
        MessageBox(NULL, (LPCTSTR)lpMsgBuf, TEXT("Error"), MB_OK); 
        return ;
    }
    

    If you just want to get the error code and look it up manually, then a complete directory of codes is available on MSDN, here, I would guess that ERROR_ACCESS_DENIED
    (5)
    is most probable. A more elaborate example of error code display is given here.

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

Sidebar

Related Questions

I have a 32-bit application that must run on a Windows x64 server using
I am using windows application and I have four combo boxes(comboeventname,combosendtype,comboType,comboschedule) in that form....
I have a program that I would like to run on just one CPU
I have an app that I wrote using C# .NET 4.0 in Visual Studio
I have an f# script using Windows Forms and I want it to run
Using windows server, I have a path to a file that, when you click
I have an ASP.Net application where I am using Windows authentication to deny access
We have implemented SSO in a .NET web application using Windows Identity Foundation (WIF).
new on rails and using windows for now,, i have web page that user
I'm working on a solution in Visual Studio 2010 Ultimate that contains two C#

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.