Access97, VBA, Win32, API, Windows95: CreateEvent returns 0 with Windows95 
Author Message
 Access97, VBA, Win32, API, Windows95: CreateEvent returns 0 with Windows95

Under NT4 the follwing code works well, but under Win95 it does not, as
CreateEvent returns 0. Why?

  Declare Function CreateEvent Lib "kernel32" Alias "CreateEventA"
(lpNull As Any, ByVal bManualReset As Long,   ByVal bInitialState As
Long, ByVal lpName As String) As Long

  Dim bManualReset As Long, ev_Start As Long, bInitialState As Long,
lpName  As String

  bManualReset = True  'no automatic reset after one waiting thread is
released
  bInitialState = False 'nonsignaled

  lpName = "S32BDE_Start"
  ev_Start = CreateEvent(Null, bManualReset, bInitialState, lpName)

Many thanks for your help

Manfred



Sat, 30 Dec 2000 03:00:00 GMT  
 Access97, VBA, Win32, API, Windows95: CreateEvent returns 0 with Windows95
Manfred,

 > under Win95 it does not, as
 > CreateEvent returns 0. Why?

GetLastError() might help in answering the "Why?" part.

--

Cheers,

Felix.

If you post a reply, kindly refrain from emailing it, too.

No anti-spam address here. Just one comment: IN YOUR FACE!



Sat, 30 Dec 2000 03:00:00 GMT  
 Access97, VBA, Win32, API, Windows95: CreateEvent returns 0 with Windows95

Quote:

> Manfred,

>  > under Win95 it does not, as
>  > CreateEvent returns 0. Why?

> GetLastError() might help in answering the "Why?" part.

GetLastError returns a 0 too! :-(

after the call to ev_... = CreateEvent(...) the code goes:
if ev_... = 0 then
  LastError=getLastError()
  Msgbox "Error: " LastError ...

Quote:
> --

> Cheers,

> Felix.

> If you post a reply, kindly refrain from emailing it, too.

> No anti-spam address here. Just one comment: IN YOUR FACE!



Sat, 30 Dec 2000 03:00:00 GMT  
 Access97, VBA, Win32, API, Windows95: CreateEvent returns 0 with Windows95
Hi Manfred,

If memory serves, this discrepancy might be due to SECURITY_ATTRIBUTES.  You
might want to try declaring it as

Declare Function CreateEvent Lib "kernel32" Alias "CreateEventA"
(lPSecurityStuff As Long, ByVal bManualReset As Long,   ByVal bInitialState
As
Long, ByVal lpName As String) As Long

and calling it with a 0& for lpSecurityStuff.  I don't think
SECURITY_ATTRIBUTES is completely supported in Win95.  Can't check it at the
moment though.... Sorry.

HTH
--
Dev Ashish (Just my $.001)
---------------
The Access Web ( http://home.att.net/~dashish )
---------------

:Under NT4 the follwing code works well, but under Win95 it does not, as
:CreateEvent returns 0. Why?
:
:  Declare Function CreateEvent Lib "kernel32" Alias "CreateEventA"
:(lpNull As Any, ByVal bManualReset As Long,   ByVal bInitialState As
:Long, ByVal lpName As String) As Long
:
:  Dim bManualReset As Long, ev_Start As Long, bInitialState As Long,
:lpName  As String
:
:  bManualReset = True  'no automatic reset after one waiting thread is
:released
:  bInitialState = False 'nonsignaled
:
:  lpName = "S32BDE_Start"
:  ev_Start = CreateEvent(Null, bManualReset, bInitialState, lpName)
:
:Many thanks for your help
:
:Manfred
:
:
:



Sat, 30 Dec 2000 03:00:00 GMT  
 Access97, VBA, Win32, API, Windows95: CreateEvent returns 0 with Windows95
Hi Dev

I think too, that it is due to  lpEventAttributes (as LPSECURITY_ATTRIBUTES). In
the descrption of CreateEvent I read >Windows95: The lpSecurityDescriptor member
of the structur is ignored<.

I tried your proposal, but it does not work under NT, as CreateEvent returns 0

I am also disturbed as GetLastError does not return an error, it returns 0

Manfred

Quote:

> Hi Manfred,

> If memory serves, this discrepancy might be due to SECURITY_ATTRIBUTES.  You
> might want to try declaring it as

> Declare Function CreateEvent Lib "kernel32" Alias "CreateEventA"
> (lPSecurityStuff As Long, ByVal bManualReset As Long,   ByVal bInitialState
> As
> Long, ByVal lpName As String) As Long

> and calling it with a 0& for lpSecurityStuff.  I don't think
> SECURITY_ATTRIBUTES is completely supported in Win95.  Can't check it at the
> moment though.... Sorry.

> HTH
> --
> Dev Ashish (Just my $.001)
> ---------------
> The Access Web ( http://home.att.net/~dashish )
> ---------------



Sun, 31 Dec 2000 03:00:00 GMT  
 Access97, VBA, Win32, API, Windows95: CreateEvent returns 0 with Windows95
Manfred,

got it.

The function name is, for you, "CreateEventA" if that VBA junk uses
ANSI. If VBA passes Unicode strings to functions, use "CreateEventW".
Sorry, but one tends to forget that some languages lack a preprocessor
to hide the tedious A/W thing.

--

Cheers,

Felix.

If you post a reply, kindly refrain from emailing it, too.

No anti-spam address here. Just one comment: IN YOUR FACE!



Sun, 31 Dec 2000 03:00:00 GMT  
 Access97, VBA, Win32, API, Windows95: CreateEvent returns 0 with Windows95
There's a simple solution, as it works this way:

    Dim bInitialState As Long, ev_Start as long
    Dim lpEventAttributes As SECURITY_ATTRIBUTES

    With lpEventAttributes
      .nLength = 12
      .lpSecurityDescriptor = 0&
      .bInheritHandle = True
    End With

    bManualReset = True  'no automatic reset after one waiting thread is
released
    bInitialState = False 'nonsignaled

    lpName = "Start"
    ev_Start = CreateEvent(lpEventAttributes, bManualReset, bInitialState,
lpName)

With lpEventAttributs = Null, as it seems possible according to docu, it
will work with NT, but not with Win95

Quote:

> Under NT4 the follwing code works well, but under Win95 it does not, as
> CreateEvent returns 0. Why?

>   Declare Function CreateEvent Lib "kernel32" Alias "CreateEventA"
> (lpNull As Any, ByVal bManualReset As Long,   ByVal bInitialState As
> Long, ByVal lpName As String) As Long

>   Dim bManualReset As Long, ev_Start As Long, bInitialState As Long,
> lpName  As String

>   bManualReset = True  'no automatic reset after one waiting thread is
> released
>   bInitialState = False 'nonsignaled

>   lpName = "S32BDE_Start"
>   ev_Start = CreateEvent(Null, bManualReset, bInitialState, lpName)

> Many thanks for your help

> Manfred



Tue, 02 Jan 2001 03:00:00 GMT  
 Access97, VBA, Win32, API, Windows95: CreateEvent returns 0 with Windows95
:Manfred,
:
:got it.
:
:The function name is, for you, "CreateEventA" if that VBA junk uses
:ANSI. If VBA passes Unicode strings to functions, use "CreateEventW".
No. VB(A) passes ANSI strings to functions, but converts them from Unicode
internally. It also converts returned strings from ANSI to Unicode.
FYI, this is what you are looking for:
' change lpEventAttributes to Any/Long if you need to pass a NULL.
Declare Function CreateEvent Lib "kernel32" Alias "CreateEventA"
(lpEventAttributes As SECURITY_ATTRIBUTES, ByVal bManualReset As Long, ByVal
bInitialState As Long, ByVal lpName As String) As Long

:Sorry, but one tends to forget that some languages lack a preprocessor
:to hide the tedious A/W thing.
So!?

--
Damit Senanayake
ICQ#: 6930718
#include <stdio.h>
#include <ctype.h>
void main(){ const char* s="\x044\x061\x06D\x069\x074";char* d="";for(int
i=0;i<6;i++){d[i]=__toascii(s[i]);}puts(d);}





Sun, 14 Jan 2001 03:00:00 GMT  
 Access97, VBA, Win32, API, Windows95: CreateEvent returns 0 with Windows95
Damit,

 > FYI, this is what you are looking for:

Thanks. The original poster will, one hopes, also see your response.

 > #include <stdio.h>
 > #include <ctype.h>
 > void main(){ const char* s="\x044\x061\x06D\x069\x074";char* d="";for(int
 > i=0;i<6;i++){d[i]=__toascii(s[i]);}puts(d);}

Um, I think you are overwriting a string literal for which (a) you
haven't reserved enough room and (b) which may well be read-only,
depending on where your compiler puts string literals.

--

Cheers,

Felix.

If you post a reply, kindly refrain from emailing it, too.

No anti-spam address here. Just one comment: IN YOUR FACE!



Mon, 15 Jan 2001 03:00:00 GMT  
 Access97, VBA, Win32, API, Windows95: CreateEvent returns 0 with Windows95
Felix,

        Thanks for the laugh!

Quote:

>  > #include <stdio.h>
>  > #include <ctype.h>
>  > void main(){ const char* s="\x044\x061\x06D\x069\x074";char* d="";for(int
>  > i=0;i<6;i++){d[i]=__toascii(s[i]);}puts(d);}

> Um, I think you are overwriting a string literal for which (a) you
> haven't reserved enough room and (b) which may well be read-only,
> depending on where your compiler puts string literals.

> --

> Cheers,

> Felix.

> If you post a reply, kindly refrain from emailing it, too.

> No anti-spam address here. Just one comment: IN YOUR FACE!

--

Mike Collins
http://www.psi3164.com



Mon, 15 Jan 2001 03:00:00 GMT  
 Access97, VBA, Win32, API, Windows95: CreateEvent returns 0 with Windows95


:Thanks. The original poster will, one hopes, also see your response.
That is, of course, if the MS server doesn't start "dropping" posts again :)
[snip]
:Um, I think you are overwriting a string literal for which (a) you
:haven't reserved enough room and (b) which may well be read-only,
:depending on where your compiler puts string literals.
Nope. It works in VC++ 5.0
OTOH, you are right about (a). The original version was 18 char* pointers,
when I tried to access anything after 16* it crashed with Access Violation.
--
Damit Senanayake
ICQ#: 6930718
#include <stdio.h>
#include <ctype.h>
void main(){ const char* s="\x044\x061\x06D\x069\x074";char* d="";for(int
i=0;i<6;i++){d[i]=__toascii(s[i]);}puts(d);}


Thu, 18 Jan 2001 03:00:00 GMT  
 
 [ 13 post ] 

 Relevant Pages 

1. Need Win32 API Calls to find Handle of a Program Running in Windows95

2. bug in Access97 or Windows95

3. Returning the ComputerName from the Windows95 Registry

4. Internet API Reference for Windows95/98/NT

5. CreateEvent API call from VB returns 0 handle

6. Windows95 Browse for file API !!!!!!!!!!!!!!!

7. API-Declarations for the Windows95 Taskbar

8. Windows95 API with VB4

9. About API in windows95 & windows NT

10. About API in Windows95 & Windows NT

11. Accessing Windows95 Password API Problem

12. Working with windows95 explorer using Api functions

 

 
Powered by phpBB® Forum Software