473,320 Members | 1,896 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

DWORDS ? LONG? - I need to create constants for the following

Hi Everyone,

I am creating an application to interface with Terminal Services but as you
will learn I am a beginner. I have learned how to connect to the API to use
the functions available. One of the functions I would like to use is the
following:

BOOL WTSWaitSystemEvent(
HANDLE hServer,
DWORD EventMask,
DWORD* pEventFlags
);

The following are my available choices for [DWORD EventMask]:

#define WTS_EVENT_NONE 0x00000000
#define WTS_EVENT_CREATE 0x00000001
#define WTS_EVENT_DELETE 0x00000002
#define WTS_EVENT_RENAME 0x00000004
#define WTS_EVENT_CONNECT 0x00000008
#define WTS_EVENT_DISCONNECT 0x00000010
#define WTS_EVENT_LOGON 0x00000020
#define WTS_EVENT_LOGOFF 0x00000040
#define WTS_EVENT_STATECHANGE 0x00000080
#define WTS_EVENT_LICENSE 0x00000100
#define WTS_EVENT_ALL 0x7fffffff <-- I am not sure how to convert
these and what they are?
#define WTS_EVENT_FLUSH 0x80000000

The constants will be Long in Visual Basic but how can I define what the
constant value will be? What will the long numerical value be? Hope I am
making sense..

Thanks
Jeremie Legault
jl******@systemfix.ca
Apr 28 '06 #1
4 2571
Might have found my own answer, can someone confirm for me?

Is this right?
#define WTS_EVENT_NONE 0x00000000 = 0
#define WTS_EVENT_CREATE 0x00000001 = 1
#define WTS_EVENT_DELETE 0x00000002 = 2
#define WTS_EVENT_RENAME 0x00000004 = 4
#define WTS_EVENT_CONNECT 0x00000008 = 8
#define WTS_EVENT_DISCONNECT 0x00000010 = 16
#define WTS_EVENT_LOGON 0x00000020 = 32
#define WTS_EVENT_LOGOFF 0x00000040 = 64
#define WTS_EVENT_STATECHANGE 0x00000080 = 128
#define WTS_EVENT_LICENSE 0x00000100 = 256
#define WTS_EVENT_ALL 0x7fffffff = 2147483647
#define WTS_EVENT_FLUSH 0x80000000 = 2147483648

Thanks
Jeremie Legault
jl******@systemfix.ca

"Jeremie Legault" wrote:
Hi Everyone,

I am creating an application to interface with Terminal Services but as you
will learn I am a beginner. I have learned how to connect to the API to use
the functions available. One of the functions I would like to use is the
following:

BOOL WTSWaitSystemEvent(
HANDLE hServer,
DWORD EventMask,
DWORD* pEventFlags
);

The following are my available choices for [DWORD EventMask]:

#define WTS_EVENT_NONE 0x00000000
#define WTS_EVENT_CREATE 0x00000001
#define WTS_EVENT_DELETE 0x00000002
#define WTS_EVENT_RENAME 0x00000004
#define WTS_EVENT_CONNECT 0x00000008
#define WTS_EVENT_DISCONNECT 0x00000010
#define WTS_EVENT_LOGON 0x00000020
#define WTS_EVENT_LOGOFF 0x00000040
#define WTS_EVENT_STATECHANGE 0x00000080
#define WTS_EVENT_LICENSE 0x00000100
#define WTS_EVENT_ALL 0x7fffffff <-- I am not sure how to convert
these and what they are?
#define WTS_EVENT_FLUSH 0x80000000

The constants will be Long in Visual Basic but how can I define what the
constant value will be? What will the long numerical value be? Hope I am
making sense..

Thanks
Jeremie Legault
jl******@systemfix.ca

Apr 28 '06 #2

Jeremie Legault wrote:
Hi Everyone,

I am creating an application to interface with Terminal Services but as you
will learn I am a beginner. I have learned how to connect to the API to use
the functions available. One of the functions I would like to use is the
following:

BOOL WTSWaitSystemEvent(
HANDLE hServer,
DWORD EventMask,
DWORD* pEventFlags
);

The following are my available choices for [DWORD EventMask]:

#define WTS_EVENT_NONE 0x00000000
#define WTS_EVENT_CREATE 0x00000001
#define WTS_EVENT_DELETE 0x00000002
#define WTS_EVENT_RENAME 0x00000004
#define WTS_EVENT_CONNECT 0x00000008
#define WTS_EVENT_DISCONNECT 0x00000010
#define WTS_EVENT_LOGON 0x00000020
#define WTS_EVENT_LOGOFF 0x00000040
#define WTS_EVENT_STATECHANGE 0x00000080
#define WTS_EVENT_LICENSE 0x00000100
#define WTS_EVENT_ALL 0x7fffffff <-- I am not sure how to convert
these and what they are?
#define WTS_EVENT_FLUSH 0x80000000

The constants will be Long in Visual Basic but how can I define what the
constant value will be? What will the long numerical value be? Hope I am
making sense..


If you are using VB.CLASSIC - then yes, they would be Long... But,
since this is a VB.NET group, I'll assume your using VB.NET - and in
that case, they will be integers. Integer in VB.NET is a 32-bit
number, not 16-bit as in VB.CLASSIC. A Long in VB.NET is actually a
64-bit number.

Anyway - to declare these:

Private Const WTS_EVENT_ALL As Integer = &H7FFFFFFF

In other words, change the 0x to an &H :) These look like a bunch of
flags that are going to be or'd together, so in reality I would
probably make these an Enum...

<Flags()> _
Private Enum EventFlags
None = &H0
Create = &H1
Delete = &H2
Rename = &H4
Connect = &H8
Disconnect = &H10
Logon = &H20
Logoff = &H40
StateChange = &H80
License = &H100
All = &H7FFFFFFF
Flush = &H80000000
End Enum

And then I would delcare the parameter that I was passing these to as
EventFlags. This way you get a handy intellisense on what flags are
valid :)

HTH

--
Tom Shelton [MVP]

Apr 28 '06 #3
"Jeremie Legault" <Je************@discussions.microsoft.com> schrieb:
Might have found my own answer, can someone confirm for me?
[...]
#define WTS_EVENT_FLUSH 0x80000000 = 2147483648


I don't see any reasons for transforming the hexadecimal literals into
decimal literals. Simply replace the '0x' with '&H' in VB.NET:

\\\
Private Const WTS_EVENT_FLUSH As Int32 = &H80000000
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Apr 28 '06 #4
"Jeremie Legault" <Je************@discussions.microsoft.com> schrieb:
I am creating an application to interface with Terminal Services but as
you
will learn I am a beginner. I have learned how to connect to the API to
use
the functions available. One of the functions I would like to use is the
following:

BOOL WTSWaitSystemEvent(
HANDLE hServer,
DWORD EventMask,
DWORD* pEventFlags
);


\\\
Private Declare Function WTSWaitSystemEvent Lib "Wtsapi32.dll" ( _
ByVal hServer As IntPtr, _
ByVal EventMask As WTS_EVENT_FLAGS, _
ByRef pEventFlags As Int32 _
) As Boolean

<Flags()> _
Private Enum WTS_EVENT_FLAGS
WTS_EVENT_NONE = &H0
WTS_EVENT_CREATE = &H1
WTS_EVENT_DELETE = &H2
WTS_EVENT_RENAME = &H4
WTS_EVENT_CONNECT = &H8
WTS_EVENT_DISCONNECT = &H10
WTS_EVENT_LOGON = &H20
WTS_EVENT_LOGOFF = &H40
WTS_EVENT_STATECHANGE = &H80
WTS_EVENT_LICENSE = &H100
WTS_EVENT_ALL = &H7FFFFFFF
WTS_EVENT_FLUSH = &H80000000
End Enum
///

The enumeration type is implicitly typed as 'Int32'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Apr 28 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Peter Kwan | last post by:
Hi, I believe I have discovered a bug in Python 2.3. Could anyone suggest a get around? When I tested my existing Python code with the newly released Python 2.3, I get the following warning: ...
2
by: Bryan Olson | last post by:
The current Python standard library provides two cryptographic hash functions: MD5 and SHA-1 . The authors of MD5 originally stated: It is conjectured that it is computationally infeasible to...
8
by: J.Haan | last post by:
Hi all. I'm currently coping with a problem on which I hope you could shed some light. Imagine the following: I have table in DB2 8.1 (.5) which is defined as: table test { t1 smallint,...
6
by: Danny Lesandrini | last post by:
I'm using an Access database to drive a web site and the colors of various table backgrounds are stored in Access. I want users of the Access database to be able to select colors for the site, but...
26
by: Christopher Benson-Manica | last post by:
I have, in a certain unnamed header file, the following: #define PIPE_WAIT 0x00000000 #define PIPE_NOWAIT 0x00000001 and a function that the compiler believes...
24
by: Michael B Allen | last post by:
I use long longs occasionally. I know there are some limitations regarding the standards such as not using long long constants but what's the big deal? Why is long long not used so much? Mike
9
by: rsine | last post by:
I have developed a program that sends a command through the serial port to our business system and then reads from the buffer looking for a number. Everything worked great on my WinXP system, but...
12
by: Laurent Deniau | last post by:
If I understand well, an enumeration is only garantee to hold at most an int (6.7.2.2-2). So I would like to know: how to store a long in an enum? enum { p2_31 = 1L << 31 }; // boom how to...
52
by: lcw1964 | last post by:
Greetings, all, I am trying to port a little bit of math code to gcc, that in the original version used the long double version of several functions (in particular, atanl, fabsl, and expl). I...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.