|
Dear All,
I have an application which connects to remote machine. I want to check the behavior of this application when remote machine is suddenly restarted. For this purpose, i have to physically access remote machine and restart it. After that i check how my application behaves.
By restarting the remote machine, i am actually making that remote machine inaccessible. Now i want to do it programatically so that i don't need to physically connect to remote machine to restart it.
How can i make a "remote" machine inaccessible from my local box for a certain time ? I want to do it programatically. By making remote machine "inaccessible" doesn't necessarily mean that i restart it. What i want to do is to just temporarily make it inaccessible from my local box.
Imtiaz
|
|
|
|
|
Unplug the network cable on your machine.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
You can use PsExec utility to restart a remote computer.
Or you can use Remote Desktop Connection Application (mstsc.exe) to connect with remote computer and Shutdown.
Restart,or if you remove the network, both will result a broken network connection.
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
i difine a custom message(i want to post it to a driver)
#define WM_INTERRUPT WM_USER+100
then i use it as a parameter in the function DeviceIoControl
<br />
...<br />
ULONG nBytesRead;<br />
<br />
if (! DeviceIoControl(<br />
m_hPCI9054, <br />
IOCTL_SET_NOTIFICATION_EVENT, <br />
&WM_INTERRUPT, <br />
sizeof(WM_INTERRUPT),<br />
NULL,<br />
0, <br />
<br />
&nBytesRead,<br />
NULL<br />
)<br />
...
it makes an error:
...'DeviceIoControl' : cannot convert parameter 3 from 'const int' to 'void *'
how to fix it?
i 've tried ,then i have no regret
|
|
|
|
|
You have defined WM_INTERRUPT as a preprocessor symbol. During compilation, the compiler is going to simply replace all occurrences of WM_INTERRUPT with the number 1124 . So what you're trying to do essentially, is this - &1124 which of course, does not make sense. Depending on how you have implemented your driver you can choose to pass WM_INTERRUPT directly like so - (void *)WM_INTERRUPT . This will of course, mean that you should not be dereferencing this value from your driver.
|
|
|
|
|
The parameter should not be constant as per the documentation. Do as follows
LONG lData = WM_INTERRUPT;<br />
<br />
ULONG nBytesRead;<br />
<br />
if (! DeviceIoControl(<br />
m_hPCI9054, <br />
IOCTL_SET_NOTIFICATION_EVENT, <br />
&lData, <br />
sizeof(WM_INTERRUPT),<br />
NULL,<br />
0, <br />
&nBytesRead,<br />
NULL<br />
)
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
Hi,
Would anyone know in which of the overrideable methods can I set the Window Name ??
::SetWindowText just seems to set the Text When I do I a FindWindow for that string I dont seem to find it
|
|
|
|
|
What exactly do you mean by Window Name if you're not referring to its text/title?
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I dont undrestand what do you need?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
I am converting a program I wrote in C to MFC
In C
I used CreateWindow to Create the Main Window and the Second Param
LPCTSTR lpWindowName,
Was the Window Name
I am able to Do A FindWindow on this to get the Window Handle
When I converted the Program to MFC the Wizard Creatred a bucnh of Objects
Cwnd .. (guess for the Client Are .. CFrameWnd for the Frame
I guess I was looking for Where .. Some overrideable method to insert the Window
Title
When I tried doing it durning ::OnCreate using SetWindowText the Window title Displayed but the FindWidnow
didn't get the Window Handle
Durning PreCreateWindow setting the Window name by setting lpszName memeber of CreateStruct structure
The Program bombed
I am using FindWidow in Dos App to Do IPC with the GUI PROGRAM
thankx
|
|
|
|
|
|
|
Just looked up the API on MSDN for this API I need the Class name in My Case I used AFXregisterclassname
|
|
|
|
|
I have a class called subscriber in a project. Several classes inherit from it but as of now, none use the functionality. The destructor is empty but calls the STL <list> destructor. Since the class isn't used yet, the list is empty. This then crashes the program when shutting down because the empty list of pointers creates a null pointer in the <list> destructor. Is it me or aren't empty lists supposed to disappear without trying to empty themselves?
Class is below.
Mark Jackson
class subscriber
{
public:
subscriber() {}
subscriber(const subscriber& s);
~subscriber() {}
virtual void update() = 0;
void subscribe(broadCaster * b);
void unSubscribe(broadCaster * b);
void unSubscribe();
private:
std::list<broadCaster *> _mBroadList;
typedef std::list<broadCaster *>::iterator iterator;
}; // subscriber
|
|
|
|
|
mjackson11 wrote: because the empty list of pointers creates a null pointer in the <list> destructor
Huh ??
if no one "subscribe" the list will be empty; the size will be zero.
if there are subscription, then the list will be non-empty; it's not the job of the subscriber class to delete the broadCaster; so no major
cleaning to be done here.
in the destructor, I would do (just to be certain)
_mBroadLost.clear();
This signature was proudly tested on animals.
|
|
|
|
|
Duh, careless virtual in a baseclass declaration led to multiple calls to the destructor.
|
|
|
|
|
Using pointers to things as the element type template parameter to STL collections can be somewhat tricky. Is there any reason in particular why you are using a list<broadCaster *> instead of just list<broadCaster> ? With a list of pointers to broadCaster objects, maintaining the lifetime of the objects pointed at by those pointers typically becomes an issue. This is just a general guideline though - depending on your specific requirements it might make sense to do this.
|
|
|
|
|
BTW, Make your destructor virtual. If you're accessing derived class object though base class point and if you delete it, derived class constructor will not be called.
See FAQ[^]
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
Hi
Why I can't see the result of my program (Win32 Console Application)in Vc++8.
for example:
#include <iostream>
using namespace std;
int main()
{
cout << "The First Program - Welcome";
return 0;
}
thank you
soso
|
|
|
|
|
anassamar wrote: Why I can't see the result of my program (Win32 Console Application)in Vc++8.
What do you mean by 'result'?
How have you executed the program?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Because you are running it from within the IDE. You can either call getch() after cout , or run the program from a command prompt.
"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 all,
With C++ I/O functions, I'm trying to read in file contents but search for a particular point in the file. For example:
int main() {
string line;
ifstream inFile;
inFile.open("C:\\LOCATIONOFFILE\\Desktop\\the.msg");
if (!inFile) {
cout << "Unable to open file";
exit(1);
}
if (inFile.is_open())
{
while (! inFile.eof() )
{
getline (inFile,line);
cout << line << endl;
}
inFile.close();
}
return 0;
This reads in the first line of the file.
1. Is there a way to read in a specific line number? Something like getline (inFile,lineNumber100) ?
2. Can I point to a specific position in the line?
3. How can I apply regex to this in order to search entire files for particular strings in a file?
Sorry to be a pain but, if anyone can help...
Thanks
modified on Thursday, March 12, 2009 5:54 PM
|
|
|
|
|
su_penguin wrote: 1. Is there a way to read in a specific line? Something like getline (inFile,lineNumber100) ?
No - lines are all of different lengths.
su_penguin wrote: 2. Can I point to a specific position in the line?
Once you've read it in? Yes- line.begin() + the_position_you_want_remember_its_zero_based
su_penguin wrote: 3. How can I apply regex to this in order to search entire files for particular strings in a file?
Using Boost.Regex[^] or std::tr1::iterator (as included in VS2008), I'd read the file into a string and then use a regex_iterator or regex_token_iterator to search through the string. You can't search through the file directly with regex_iterator or regex_token_iterator because an istream_iterator (the iterator for files) doesn't have the characteristics required for regex iterators.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Stuart Dootson wrote: su_penguin wrote:1. Is there a way to read in a specific line? Something like getline (inFile,lineNumber100) ? No - lines are all of different lengths.
Yes, you can't directly jump to a specific file offset if each line in the file can be of a different length. You could scan for "new line" characters and skip (N - 1) "new lines" where N is the line number that you want to navigate to. But figuring out what exactly is a "new line" can be tricky ("\n" on POSIX, "\r\n" on Windows, "\r" on macs).
|
|
|
|