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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:03:17+00:00 2026-05-13T08:03:17+00:00

I made an application and a dll, which are working this way: I have

  • 0

I made an application and a dll, which are working this way:
I have to register the dll. After registering the dll if i right click on an .exe file, the pop-up menu appears, and i have inserted into this menu one line (“Start MyApp”), and if i click there, it should start MyApp. MyApp has one parameter which is the full path of the selected .exe file. After starting MyApp with this path it should create a process with CreateProcessWithLogonW(). This application reads the username, password and the domain from an .ini file. My problem is, that after MyApp starts, it fails always, because it can’t find the ini file. Errorcode is: 1 (Incorrect function).
If i start MyApp manually, than it works fine.

Does anyone has any idea why is this, and how could i fix this problem?

Thanks in advance!

kampi

Update1:

Here is the code which reads from the ini file.

int main ( int argc, char *argv[] )  
{    
  int i, slash = 0, j;  
  char application[size];  
  wchar_t wuser[65], wdomain[33], wpass[129];  

  memset( user, 0, sizeof ( user ) );
  memset( password, 0, sizeof ( password ) );
  memset( domain, 0, sizeof ( domain ) );

  file_exists( "RunAs.ini" );
  readfile( "RunAs.ini" );  
  ....
  ....
  ....
}  
void file_exists( const char * filename )  
{  
  if (FILE * file = fopen(filename, "r"))  
  {  
      fclose(file);  
  }  
  else   
  {  
      printf("\nCan't find %s!\n",filename);  
      getch();  
      exit(1);  
  }   
}//file_exists    

void readfile( char * filename )
{  
     FILE *inifile;  
    char tmp[256], buf[256], what[128];  
    int i, j;  

    inifile = fopen( "RunAs.ini", "r" );  

    while ( fgets(tmp, sizeof tmp, inifile) != NULL )  
    {     
        if ( tmp[ strlen(tmp) - 1 ] == '\n' )  
         {  
            tmp[ strlen(tmp) - 1 ] = '\0';  
        }//if  

        memset ( buf, 0, sizeof( buf ) );  

        for ( i = 0; tmp[i]!= '='; i++ )  
         {  
             buf[i] = tmp[i];  
         }  
        buf[i] = '\0';  
        i++;  

    //  memset ( what, 0, sizeof( what ) );  
        SecureZeroMemory( what, sizeof(what) * 128 );  

        for ( j = 0; i != strlen(tmp); i++ )   
         {  
             what[j] = tmp[i];  
            j++;  
         }  
        what[j] = '\0';  
        upcase( buf );  
        removespace( what );  

        if ( strcmp( buf, "USERNAME" ) == 0 )  
        {  
            strcpy( user, what );  
        }  
        if ( strcmp( buf, "PASSWORD" ) == 0 )  
        {  
            strcpy( password, what );  
        }  
        if ( strcmp( buf, "DOMAIN" ) == 0 )  
        {  
            strcpy( domain, what );  
        }  
    }//while  
    fclose (inifile);  

}//readfile  
  • 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-13T08:03:17+00:00Added an answer on May 13, 2026 at 8:03 am

    As others have said, your problem is here:

    file_exists( "RunAs.ini" );
    readfile( "RunAs.ini" );  
    

    Neither of the function calls provides a path. You’re expecting the current working directory to be the folder where your application is located, but it doesn’t have to be (in fact, you should never assume that it is). The context menu isn’t setting the working directory first.

    Your safest bet is to retrieve the path to your folder using the path provided in argv[] (the 0th element is the fully qualified path and name of the application itself, and you can extract the path from that). You’ll then have exact knowledge of where the file is located, and can append the name of the ini file to that path.

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

Sidebar

Related Questions

No related questions found

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.