|
Say you're calling CMyMessageBox to your MessageBox replacement; then, add with the wizard a CString member associated with the text field where the message is displayed, and modofy the ctor of CMyMessageBox so that it accepts a message and assigns it to that variable. Automatically you can have as many messages displayed as you want. You can add to your customization by letting the user select the type of message box (yes/no, accept/cancel, and so on), that's a little more dificult, but not much.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
i'm writing a small program to help me keep track of how my computer (at a remote location) is being used. My small app runs on the remote computer, and registers data every 10mins, one is how long the system has been idle. (or more precise, if it has been used the last 10 mins).
I also would like to register if the current session is a remote session (eg accessed with remote desktop), to see if i myself was accessing the computer at that point, or if some other person was using the computer locally.
Is there any api i can ask to find out if the computer is (currently) being accessed via remote desktop?
thanks
Thomas
|
|
|
|
|
The WTSRegisterSessionNotification function registers the specified window to receive session change notifications. >> So your app can know when the state has changed (a remote session joins or not?).
The WTSEnumerateSessions function retrieves a list of sessions on a specified terminal server. >> In case you are writing a service (they do not usually have windows).
The WTSGetActiveConsoleSessionId function retrieves the Terminal Services session currently attached to the physical console. The physical console is the monitor, keyboard, and mouse. Note that it is not necessary that Terminal Services be running for this function to succeed. >> To distinguish if the 'current' session is remote or not.
The WTSQuerySessionInformation function retrieves session information for the specified session on the specified terminal server. It can be used to query session information on local and remote terminal servers. >> You can find out if session is rmeote or not, and all sorts of other infromation you might want to track.
|
|
|
|
|
I am trying to monitor when a paticular process starts up.
The way I am doing it now:
I used SetTimer() to call ON_TIMER
in OnTimer() I enumerate all running process and check to see if the app I am looking for is running. If it is I create a process handle to it and call KillTimer(TimerHandle) to stop the timer messages.
Problem:
Even though I call KillTimer() I still get OM_TIMER messages and can't stop the check for the running process. Just wondering if anybody nows a better way to continually poll for running processes or if anybody knows why the call to KillTimer isn't working.
Thanks in advance.
|
|
|
|
|
Hello,
I was wondering if any of you CPers know how to solve this problem i've come across with.
I've defined about four or so methods in this class of mine as inline and, it appears, the linker cannot find the method's definitions in the .OBJ .
The only way of solving this issue is by NOT defining the method(s) as inline . How do I do about solving this, while at the same time keeping inline declaration?
Thanks a lot
David
Linker Error:
Linking...
LINK : LNK6004: Debug/xtest.exe not found or not built by the last incremental link; performing full link
xtestDlg.obj : error LNK2001: unresolved external symbol "public: char const & __thiscall XField::GetText(void)" (?GetText@XField@@QAEABDXZ)
Debug/xtest.exe : fatal error LNK1120: 1 unresolved externals
|
|
|
|
|
inline methods must come in headers. Are you by chance defining the method in some .cpp instead?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Yes, that is true.
I have defined it in the class declaration - in the header file - and I've coded the method(s) in the actual source file (.cpp ) .
I take it you mean I can't insert the code in the source file but only in the header?
David
BTW, thanks for the reply
|
|
|
|
|
Hi guys
Somebody knows what's the fast way to generate a random (or pseudorandom) array of numbers of 100.000 positions?
Thanks in advance
Doc
|
|
|
|
|
Are you wanting 100,000 numbers, or are you wanting numbers with 100,000 digits?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I want a list of 100.000 numbers randomly sorted.
Doc
|
|
|
|
|
doctorpi wrote:
I want a list...
But the subject indicates an array. I'll show an example for an array.
int nNumbers[100000];
for (int x = 0; x < sizeof(nNumbers) / sizeof(int); x++)
nNumbers[x] = rand();
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks
But maybe I haven't explained me well.
At the beginning I have an array where nNumbers[i]=i; then I have 100.000 numbers. After the process that I don't know how to do I want to have the array with all the numbers from 0 to 100.000 but unsorted.
I'm thinking in exchange 2 positions N times, but how I can generate a number between 0 and 100.000 because rand() is not valid for me.
Thanks again
Doc
|
|
|
|
|
doctorpi wrote:
...how I can generate a number between 0 and 100.000 because rand() is not valid for me.
You are right. rand() returns a maximum value of RAND_MAX . Here is a pseudo-random number generator that I've used in the past:
static unsigned long Seed = 1;
#define A 48271L
#define M 2147483647L
#define Q (M/A)
#define R (M%A)
double Random( void )
{
long TmpSeed;
TmpSeed = A * (Seed % Q) - R * (Seed / Q);
if (TmpSeed >= 0)
Seed = TmpSeed;
else
Seed = TmpSeed + M;
return (double) Seed / M;
}
void Init( unsigned long InitVal )
{
Seed = InitVal;
}
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
|
Thanks guys
I think I've got it.
Doc
|
|
|
|
|
Hi all,
We hope customers get new info from our web on time.
I want to do in this way:
add a web-page which includes some texts, i.e. "expire", "update" etc.
when program (used by customers) is running, it reads the web-page (it is hidden from customers) and does something according to texts on the page.
I don't want to use tcp/ip - we only have simply tasks.
do you know how to download a web-page silently (users don't know)?
or any other suggestions for my needed?
thx
includeh10
|
|
|
|
|
Why do you want the user to use an application which read a web page, why not use only the web page, with no application. Maybe you should use the CHTMLView, or something like that, I forgot the class
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
I know try using CWebBrowser
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
Hi, I am trying to use the PostMessage function by importing it through DLL import in C# with the following definition.
[DllImport("user32.dll")]
static extern bool PostMessage(IntPtr hWnd, int msg, Int32 wParam, IntPtr lParam);
Can someone give an example of what you would pass in order to get a keystroke, and a mouse click? Really, I do not understand what needs to go in for wParam, or lParam.
Thank you for your help in advance.
|
|
|
|
|
It depends what you need at the other end; there's a simple answer and a complicated one.
The simple answer is to look in MSDN for:
Keystroke: WM_CHAR
Mouse click: WM_xBUTTONy (where x is L or R and y is UP, DOWN or DBLCLK)
It can be more complicated if you need WM_KEYDOWN , WM_KEYUP , WM_SYSKEYDOWN , WM_SYSKEYUP , WM_SYSCHAR and so on.
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
struct S2
{
WORD w0;
};
struct S6A
{
WORD w0;
DWORD dw0;
};
struct S6B
{
WORD w0,w1;
WORD w2;
};
struct S10A
{
WORD w0;
DWORD dw0;
DWORD dw1;
};
struct S10B
{
WORD w0,w1,w2,w3,w4;
};
if use sizeof() to calculate size of structs above, they are
2, 8, 6, 12, 10 respectively (tested on windows OS - not DOS).
align? why in this way?
includeh10
|
|
|
|
|
Structs/classes are padded internally to make members aligned properly (most common CPUs other than x86 will fault on unaligned memory access). So in the case of:
struct S6A
{
WORD w0;
DWORD dw0;
}; if dw0 came right after w0 in memory, it would not lie on a DWORD boundary, so 2 bytes of padding are added to make dw0 aligned. This behavior can be changed with #pragma pack .
--
I'm Michael Dunn and I approve this post.
Vote Trogdor in oh-four!
|
|
|
|
|
By default struct s are aligned on 8-byte boundaries. If you are having alignment problems, check out the #pramga pack directive, or the /Zp compiler switch.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
DWORDS can only appear at offsets which are a multiple of four. (sizeof(DWORD))
Compilers are required to lay out a structures members in the same order as they are declared.
Put these two together... the compiler must insert padding.
|
|
|
|
|
struct S2
{
WORD w0;
};
why sizeof(S2) is 2, not 4?
includeh10
|
|
|
|