|
|
Hi,
I want to ask you that what are the different manners to run a file auto in WindowsXP and Linux? Is auto run of any file is possible in Linux? Is there any other method in windowsXP to run a file auto(makeing a autorun.inf file)?
|
|
|
|
|
Hi
I can use "wifstream" to read strings. But I can not read number (using operator >>) back from a binary file.
it seems "wifstream" that "read" function work fine and its operator >> does not functioning.
Do you have any experience with "wifstream"? Could you share it with me?
Best
|
|
|
|
|
transoft wrote: Do you have any experience with "wifstream"? Could you share it with me?
This works for me:
void main( void )
{
wofstream out("c:\\data.dat", ios::binary);
out << 123;
out.close();
wifstream in("c:\\data.dat", ios::binary);
int x;
in >> x;
in.close();
}
"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
|
|
|
|
|
Thank you very much.
I found out that "c:\\data.dat" is a text file.
I saved a number like "1". It should show in the binary file like "01 00 00 00" (using HexEditor). But your sample saved it as "1".
Thanks,
modified on Tuesday, November 3, 2009 2:01 PM
|
|
|
|
|
transoft wrote: But your sample saved it as "1".
Sorry about that. Can you just use the stream's write() method instead?
"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
|
|
|
|
|
But "Write" function can only write string to the file. The operator << suppose should be able to write number to the file. But it did not.
If you make a binary file using HexEditor like first 4 bytes looks like "01 00 00 00". Your sample can not read any thing back.
It is Microsoft fstream BUGs??? Or wifstream can only be used with text file?
|
|
|
|
|
transoft wrote: But "Write" function can only write string to the file.
It writes whatever is at the address provided to it, at least the ofstream method does.
ofstream out("c:\\data.dat", ios::trunc | ios::binary);
int y = 1234;
out.write((const char *) &y, sizeof(y));
out.close();
"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
|
|
|
|
|
Yes, Your sample works fine. But "read number" from binary file still does not work.
It is Microsoft VS 2005 BUG?
Thanks,
|
|
|
|
|
transoft wrote: But "read number" from binary file still does not work.
Are you using something like:
ifstream in("c:\\data.dat", ios::binary);
int x;
in.read((char *) &x, sizeof(x));
in.close();
"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
|
|
|
|
|
How about "wifstream"? I have to use it in my Unicode application.
wifstream operator >> still does not work.
IS there a way to convert a TCHAR string to integer number or float number? It looks like I have to use "sscanf" to convert them. What a Microsoft JUNK!!!
Thanks,
modified on Tuesday, November 3, 2009 3:15 PM
|
|
|
|
|
transoft wrote: IS there a way to convert a TCHAR string to integer number...
Have you looked at _ttoi() ?
"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
|
|
|
|
|
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.
The following solution are from Google, but I think nothing are useful for me.
1. IP Helper API. Using AddIPAddress and DeleteIPAddress: Only adds an IP
address to the adapter, will not change the current one.
2. WMI using Win32_NetworkAdapterConfiguration: I don't want this solution.
3. netsh: Using CreateProcess and passing specail command line can do it, but I don't want to do by another process(Program).
4. DhcpNotifyConfigChange: Eidt registry and call DhcpNotifyConfigChange to notify change. The problem with DhcpNotifyConfigChange is that
it's an undocumented API.And if don't call DhcpNotifyConfigChange, you have to reboot your machine to take effect.
5. SetAdapterIpAddress. This solution are done well in Win2K and WinXP. It is not working under WinVista platform. This is an undocumented API. Using an undocumented API is never ideal
Any ideas? I just want to change IP,DNS,Getway and toggle DHCP without rebooting OS.This just like the Explorer.
|
|
|
|
|
You can use bat of DOS Command, to set your ip/mask/dns that without rebooting.
like this:
netsh interface ip set address "XXXX" static 192.168.18.183 255.255.255.0 192.168.18.1 1<br />
pause<br />
netsh interface ip set DNS "XXXX" static 211.161.192.1<br />
netsh interface ip add dns "XXXX" 211.161.192.73 index=2<br />
pause<br />
|
|
|
|
|
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
|
|
|
|