Re: 'Netsh firewall reset' but from a program.



Well, this code is buggy, because the second parameter to CreateProcess
should be a pointer to a writable string, because unicode version of
function may alter the string. Read MSDN:

[...] "The Unicode version of this function, CreateProcessW, can modify the
contents of this string. Therefore, this parameter cannot be a pointer to
read-only memory (such as a const variable or a literal string). If this
parameter is a constant string, the function may cause an access violation."
[...]

--
V.
This posting is provided "AS IS" with no warranties, and confers no
rights.
"Control Freq" <nick@xxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:12afd4bd-cd28-4f52-a425-a14bf61c837c@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


Well, I don't often get to answer my own question, but I managed to
sort out a way of doing what I need.

This code snippet:

// Below does the same, but without showing a command prompt.
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
CreateProcess(NULL, "netsh firewall reset", NULL, NULL, FALSE,
CREATE_NO_WINDOW | NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi);
//

... does what I need, without showing a DOS command prompt.

Thanks.


.



Relevant Pages

  • Re: LPCSTR from String
    ... but belive this can hold pointer to both ANSI and UNICODE ... I have a String ...
    (microsoft.public.dotnet.languages.vc)
  • Re: "Mastering C Pointers"....
    ... A pointer is a kind of variable that can "point to" some object. ... has a type (pointer to int), and a value of some kind. ... You may know that you can access these integers by using array notation ... The function will take one argument, a string, and will return the length ...
    (comp.lang.c)
  • Re: pesky Pointers !!
    ... > and the function takes it as a reference instead of a copy. ... function may access the string passed directly, ... > *px dereferences the pointer to get the value ... If pTest is a pointer-to-string, *pTest is the string it points to ...
    (alt.comp.lang.learn.c-cpp)
  • Re: strtok ( ) help
    ... > splitCommandssomehow modifying the pointer, but I HAVE to call that ... Here's an idea of how to use the strtok() function. ... don't mind trashing the contents of a string s, ... will give you a loop that extracts the tokens one at a time from s. ...
    (comp.lang.c)
  • Re: Increasing efficiency in C
    ... > You don't know where the pointer will end pointing to. ... > representation of a C string. ... Wow Dan, ... My whole point is that data structure development should ...
    (comp.lang.c)