|
In the question, I have said, I don't want to do by another process(Program).
//netsh: Using CreateProcess and passing specail command line can do it, but I don't want
Dream my dream,JoeJiao!
|
|
|
|
|
JoeJiao wrote: My situation is that our users should be able to adjust their network settings (DHCP on/off, set static IP and set subnet mask) but I have yet to find a solution that is always reliable.
Using the Local Area Connection Properties dialog is too confusing?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I am sorry for bad expression.
My major target is changing IP,DNS,Getway and toggling DHCP by a c++ program, so the API is needed.But I have yet to find the solution.
If you know it, please pulish it to share with us,thanks.
Dream my dream,JoeJiao!
|
|
|
|
|
I suspect the easiest way would be to run netsh.exe from within your code. That program has been used, debugged, and tested by many. You might also glean something from this.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
In the question, I have said, I don't want to do by another process(Program).
//netsh: Using CreateProcess and passing specail command line can do it, but I don't want do by another process(Program).
I just want to know other ways to modify IP,DNS,Getway.
Can some APIs solve the question?
Dream my dream,JoeJiao!
|
|
|
|
|
Hi,
I recommend the following:
1.) Enumerate all of the network cards in the following registry path:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards
2.) Note the description and ServiceName GUID for possible later use.
3.) Enumerate the registry keys located in the following registry path:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\Interfaces
4.) Match the GUID with the network device you wish to modify.
5.) Modify the registry keys as you desire.
6.) Send a DIF_PROPERTYCHANGE notification[^] to the device class installer.
Best Wishes,
-David Delaune
|
|
|
|
|
|
Try this[^]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I'm confused. Back when I was in school, the instructor would talk (in depth) about a given topic (e.g., drawing on the board, pseudo code) and then give us an assignment based on that topic. Are you wanting us to believe that your instructor has given you an assignment without first having shown you what a B+ tree is?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
|
Fair enough. Have you considered this?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I guess 166,000 references boggled his little mind. Says something when my 5 brings their 1 up to a 4.2.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
endlesswaltzwing wrote: I am not trying to be rude here but if the answers in regards to my question are placed in a hyperlink with google.com it defeats the purpose of having people asking questions in this forum.
Then you have a lot to learn about how this forum works. People come here hourly thinking they can dump a general question about a detailed subject, and then expect a detailed reply. Last time I checked, most of the folks that help out here work for a living and help out when they have time and/or knowledge. Why would a sane person want to type paragraph after paragraph about the study and implementation of something as involved as B+ trees when they could simply point you to already existing articles?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hello,
i ran into a bit of trouble when converting unsigned short int to its hex string representation. What i need is a two byte representation with a space between the bytes (e.g "0f 43" for 3907 of "00 ff" for 255)
The solution i came up with is the following:
unsigned char* CreateHexValues(unsigned short int inValue)
{
char Hex[5] = {0, 0, 0, 0, 0};
_itoa_s(inValue, Hex, 16);
unsigned char *hexOut = new unsigned char[5];
hexOut[2] = ' ';
if(inValue <= 15)
{
hexOut[0] = '0';
hexOut[1] = '0';
hexOut[3] = '0';
hexOut[4] = Hex[0];
}
else if(inValue > 15 && inValue <= 255)
{
hexOut[0] = '0';
hexOut[1] = '0';
hexOut[3] = Hex[0];
hexOut[4] = Hex[1];
}
else if(inValue > 255 && inValue <= 4095)
{
hexOut[0] = '0';
hexOut[1] = Hex[0];
hexOut[3] = Hex[1];
hexOut[4] = Hex[2];
}
else if (inValue > 4096)
{
hexOut[0] = Hex[0];
hexOut[1] = Hex[1];
hexOut[3] = Hex[2];
hexOut[4] = Hex[3];
}
return hexOut;
}
So my question is: is there a better/quicker way to do that? The problem is that when i convert it with _itoa_s it could be in the following formats: f43, 43, 3 (depending on inValue) without any zeros in front of it. Another problem is with the Hex[5] array, my inValue can never be bigger than 65535, but for some reason i get an assertion failure when i change its size to Hex[4] which should be enough for 65535. Why could that be?
Thanks for all replies in advance
|
|
|
|
|
A simpler way is to use the one of the xprintf() type functions. Take a look here[^] at the x and X format specifiers.
|
|
|
|
|
I would do
void CreateHexValues(unsigned short inValue, char hexOut[6])
{
sprintf(hexOut, "%02x %02x", (inValue >> 8), (inValue & 0xFF) );
}
Please note: Array allocation is, by design... , responsibility of the caller.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
modified on Tuesday, November 3, 2009 9:27 AM
|
|
|
|
|
CPallini wrote: void CreateHexValues(unsigned short inValue, char hexOut[5])
Shouldn't it be hexOut[6] to make room for the \0 character?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Definitely!
Fixed: thank you!
BTW: Shhhhhhhhhhhhhhhhhhhhh, don't tell Rajesh!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thank you very much, brilliant solution 
|
|
|
|
|
How about something like:
char szBuffer[10];
short value = 1234;
sprintf(szBuffer, "%02X %02X", HIBYTE(value), LOBYTE(value));
Tony
|
|
|
|
|
hey there tell me how to communicate with the printer ... Give me a sample code
|
|
|
|
|
I don't know if you understand but your question is rather.... hum no question at all. its actually an order... a very lazy one
Why don't you try Google it!!! Its much easier and faster than waiting an answer here. Don't you think that no-one so far needed to communicate with a printer from C++? I doubt it.
here is what i found in 1 min....
http://www.mombu.com/programming/cobol/t-writing-to-printer-from-c-program-761884.html
Regards
Nikola
|
|
|
|
|
anilga wrote: hey there tell me how to communicate with the printer
hey there read the guidelines[^].
anilga wrote: Give me a sample code
printf("I am too lazy to do my own research\n");
|
|
|
|
|
What about documentation [^]?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
anilga wrote: hey there tell me how to communicate with the printer
Try soothing words. If that doesn't work, use harsh language.
|
|
|
|