Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 7th, 2004, 5:28 AM   #11
lepricaun
Hobbyist Programmer
 
lepricaun's Avatar
 
Join Date: Aug 2004
Location: The Netherlands
Posts: 111
Rep Power: 5 lepricaun is on a distinguished road
well, first of all, i did mean parameters in the WinExec() function..
second, i've altered my code to set asid memory (at least that's what i think i've done )
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
 int bufsize=256;
 char *buffer=malloc(bufsize);
 while(1)
 {
  printf("\nCommand:>");
  WinExec(buffer,SW_SHOW);
  scanf("%s",buffer);
 }  
 return 0;
}

third,
Ooble, i don't really understand what you mean by
Quote:

If there are quote marks encompassing the path, separate the path from the arguments by using two different variables ("path" and "args" are probably your best choices). If not, first check the entire string isn't a file by opening it for reading and checking the return value (look at fopen() ). If it is, execute it. Otherwise, assume the path is the entire string up to the first space. Separate the path and the arguments and add quotes round the path.

Finally, do this:

run = strcat(0x20, path);
run = strcat(args, run);
WinExec(run, SW_SHOW);
i know how the function fopen() works, but how can i make the difference between a path and a parameter like : cd c:\windows\ or control userpasswords?

thanks for the help , i really appreciate it!
__________________
http://www.white-scorpion.nl
lepricaun is offline   Reply With Quote
Old Aug 7th, 2004, 8:18 AM   #12
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
So WinExec("control userpasswords") doesn't work?
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Aug 7th, 2004, 8:29 AM   #13
lepricaun
Hobbyist Programmer
 
lepricaun's Avatar
 
Join Date: Aug 2004
Location: The Netherlands
Posts: 111
Rep Power: 5 lepricaun is on a distinguished road
not with the above code.. perhaps it does work with your code added, but like i said, i don't really understand what you mean..
this is what you see:
Quote:

Command:>control userpasswords
and then the output is:
Quote:

Command:>
Command:>
while typing "control userpasswords" in the command line pops up the account part of the control panel (like it should )
__________________
http://www.white-scorpion.nl
lepricaun is offline   Reply With Quote
Old Aug 7th, 2004, 10:03 AM   #14
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Lemme try and simplify that. If there are quotes round the path, execute it as normal. If there aren't, first check to see if the entire string is a file. If it isn't, add quotes around the first argument (up to the first space), then execute it.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Aug 7th, 2004, 11:22 AM   #15
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
First off, the reason you are getting this:

Command:>
Command:>

Is because you are executing a blank buffer. You call WinExec with buffer
before buffer is defined.

...
printf("\nCommand:>");
WinExec(buffer,SW_SHOW);
scanf("%s",buffer);
...

Try this:

printf("\nCommand:>");
scanf("%s",buffer);
WinExec(buffer,SW_SHOW);


To pass parameters to your menu... enclose the whole string in double qoutes ("myCommand myParam1 myParam2").
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Aug 7th, 2004, 11:25 AM   #16
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Make that one change... then type at your prompt type this...

Command:>"control userpasswords"

That will work for you, it brings up the userpasswords option of my control panel.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Aug 7th, 2004, 4:10 PM   #17
lepricaun
Hobbyist Programmer
 
lepricaun's Avatar
 
Join Date: Aug 2004
Location: The Netherlands
Posts: 111
Rep Power: 5 lepricaun is on a distinguished road
Quote:

First off, the reason you are getting this:

Command:>
Command:>

Is because you are executing a blank buffer. You call WinExec with buffer
before buffer is defined.

...
printf("\nCommand:>");
WinExec(buffer,SW_SHOW);
scanf("%s",buffer);
...

Try this:

printf("\nCommand:>");
scanf("%s",buffer);
WinExec(buffer,SW_SHOW);


To pass parameters to your menu... enclose the whole string in double qoutes ("myCommand myParam1 myParam2").
huh, don't know why i've missed that, i know the scanf should be before the execution, must have switched it while trying to alter the code

thanks for it, but as for the "control userpasswords", it doesn't work, not even after changing the scanf location to before the winexec location (like you said), i still only get the control panel....

did you use the above code to get the userpanel of control panels?


>>Ooble, it sounds easy, but i have NO IDEA how to code that , perhaps i need to read more manuals on strings, arrays etc....
__________________
http://www.white-scorpion.nl
lepricaun is offline   Reply With Quote
Old Aug 31st, 2004, 11:06 AM   #18
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Get C For Dummies, Volume 2 out of the library. Contains a lot of info on strings and pointers.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:47 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC