|
Well that would depend what kind of information you are looking for now wouldn't it? The canonical answer is probably WMI.
--
-Blake (com/bcdev/blake)
|
|
|
|
|
Dear all,
I am developing an application using MFC VC++ Version 6.0 for Windows 2000.
I need to capture login and log off event in my application. Is there any event (or API) to capture these events
Thanks
rohit
|
|
|
|
|
If your application is an ordinary application, it will be terminated when the user logs off, because Windows tears down the session.
Windows sends a WM_QUERYENDSESSION message, followed by a WM_ENDSESSION message, when the user logs off or shuts down the system. See the documentation for the exact semantics.
If you're trying to handle user switches on Windows XP, see the KB article HOW TO: Write an Application That Supports Fast User Switching in Windows XP[^].
(edited for formatting)
|
|
|
|
|
Thanks mike you solved my purpose
|
|
|
|
|
Can somebody help me with getting my pointer declared correctly so I can access the unsigned int x in 2 byte pieces? The book I have is very vague on how I am supposed to go about. Not much for example code. But I think I am close.
Here ya go:
<pre>typedef struct
{
unsigned short int x;
} myStruct;
void main()
{
char c;
myStruct s;
s.x = 1;
((char *) &s.x)[0]; //subscript to read first byte
printf("%d\n",&s.x);
} </pre>
|
|
|
|
|
I think your question was answered elsewhere, but it might be helpful to know about union structures to accomplish something like this.
Example:
union PeekInt {
unsigned short int i;
struct {
char b1;
char b2;
} bytes;
} mpi; This specifies that the mpi.bytes structure occupies the same memory space as mpi.i , so mpi.bytes.b1 will let you access the first byte and mpi.bytes.b2 will let you access the second byte.
- Mike
|
|
|
|
|
Yes, thank you for that example. Thats what my book(Daniel W. Lewis, "Fundamentals of Embedded Software") needs to focus on, putting more examples in it. It don't really show you much examples or how to's, it just assumes everything is bread and butter to you. Very frustrating. With your example and a few other tips I got from this forum, I am going to be ready for the test tomorrow.
Thank you.
Brian.
|
|
|
|
|
Hi I have MS Visual C++ 1.32, is there any possible way I can upgrade to something newer without paying the cost of 6.0 itself. I mean, is there a free way to upgrade to 4.0 or 5.0 or even 6 without buying the full 6.0 version.
I may sound cheap, but I'm in a college class for C++ and It would really help me if I had a newer version. 1.32 doesn't work with all the code that 6.0 does.
Well if there is anyway to upgrade I would really appreaciate the help!
Sincerely
Matt
|
|
|
|
|
It's amazing that you have version 1.32! The oldest version I have is 1.52c. You can pick up version 6.0 Professional for about $50 at this EBay auction[^] if you hurry. Good luck!
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
For a definitive answer, check out this Web site! It looks like the oldest version they'll let you upgrade from is 5.
These may also be of interest to you:
http://www.msdnaa.net/factspage.aspx
http://www.microsoft.com/education/?ID=HowToBuy
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
|
Can somebody tell me what I am doing wrong what the correct syntax is for formatting your output in binary representation.
I have been using printf("%b\n",variable) like the the help files says in .NET but it just keeps outputing a b on the console.
And does anyone know the correct syntax in C for packing your structures?
Help.
Thanks.
|
|
|
|
|
I think you have been looking at the wrong printf format specification.
There is no format that outputs binary in C (neither std or ms extension).
There is no specific packing or alignment keywords in C.
Use the pack pragma and the align declspec.
|
|
|
|
|
Okay, I found something about that pragma but Im not sure how it works with packing the data. Hmmm. Got any ideas.
I found: pragma pack(push, 1) or something like that. Not sure what it does though.
Does C++ have binary formatting?
|
|
|
|
|
About formating, nope. Actually it is printf that lacks it and it's the same for both languages.
Concerning packing, what are you trying to accomplish? Kind of hard to try to help without more info...
|
|
|
|
|
What I'm trying to do is write a struct in C with a couple data types in it, i.e. int, char.
<pre>typedef struct
{
int x;
char c;
}_attribute_((packed))myStruct</pre>
This syntax is for djgpp compiler, I was wondering what you use for .NET or Visual C 6.
|
|
|
|
|
#pragma pack(push, 1)
What this does is set the struct packing to 1-byte boundaries (i.e., no padding), while saving the previous packing. Specify this before your struct, then use #pragma pack(pop) after the struct to restore the old packing. Example:
<br />
#pragma pack(push,1)<br />
struct MyStruct {<br />
int foo;<br />
char a;<br />
};<br />
#pragma pack(pop)<br />
- Mike
|
|
|
|
|
Thanks for the help, hopefully with I can get this thing working.
|
|
|
|
|
Sirrius wrote:
Can somebody tell me what I am doing wrong what the correct syntax is for formatting your output in binary representation.
I have been using printf("%b\n",variable) like the the help files says in .NET but it just keeps outputing a b on the console.
You'll need to write a xxxToBinary() conversion routine. Then you can use printf("%s\n", ...) to output the result.
Sirrius wrote:
And does anyone know the correct syntax in C for packing your structures?
By default, structures are aligned on 8-byte boundaries. To align on some other boundary, such as 4 bytes, use:
#pragma pack(4)
before the structure/union is declared.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Thanks for the advice on the packing. Im not to clear on the xxxToBinary() conversion routine you talked about. How do I go about doing that?
Thanks for your help.
|
|
|
|
|
Here's a sample:
void DWORD_To_BinaryString(DWORD value,char string[])
{
for (int bit = 0; bit < 32; bit++) {
DWORD mask = 0x80000000 >> bit;
if ((value & mask) == mask) string[bit] = '1';
else string[bit] = '0';
}
string[32] = '\0';
} Note that this function converts any 32-bit value to a 32 character string or 1's and 0's. The destination array must be at least 33 characters long.
Software Zen: delete this;
|
|
|
|
|
I'm using embedded structures, and would like to access members of the embedded structure, but am having difficulties with the compiler accepting code regarding the instantiation of the embedded structure. Here's the code:
struct MajorStruct
{
struct MinorStruct
{
int cnt;
};
};
=====================
later on I do this:
====
MajorStruct majStruct;
majStruct.MinorStruct minStruct;
minStruct.cnt = 0;
The error from the compiler is that I cannot have a C-style cast right of the "." operator.
How do I instantiate the embedded structure so that access to its members can be obtained?
Thanks for any suggestion!
William
Fortes in fide et opere!
|
|
|
|
|
The nested struct is instantiated as part of its parent, so you don't want to instantiate it separately. To access its members try: majStruct::MinorStruct.cnt = 0;. Mind you I could be wrong here.;)
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Err, no, I think you're wrong.
What you have there is a nested class. The struct MinorStruct is scoped within the MajorStruct structure. This applies to the visibility of names.
However, it's just another struct. Just because it's declared inside MajorStruct doesn't mean that MajorStruct gets a MinorStruct member; you have to explicitly say so.
To create a variable of type MinorStruct , you need to declare it as
MajorStruct::MinorStruct minStruct; Note the use of the scope resolution operator :: and the use of the class name, not the object name, for the outer scope.
If you want MajorStruct to have a member of type MinorStruct , say:
struct MajorStruct
{
struct MinorStruct
{
int cnt;
};
MinorStruct m_minStruct;
}; You can refer to MinorStruct using simply its name within the scope of MajorStruct .
|
|
|
|
|
Thanks for replying. Your suggestion provided the solution!!
William
Fortes in fide et opere!
|
|
|
|