954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Error 998 in VB6 on Vista Home Premium

I am trying to call the GetLayeredWindowAttributes(hwnd, crKey, bAlpha, dwFlags) function but it does not work.

I use Visual Basic 6 on Windows Vista Home Premium.


I declared it using:

Private Declare Function GetLayeredWindowAttributes Lib "user32.dll" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Boolean


I called it using:

Dim byteAlpha As Byte, hwnd As Long

byteAlpha = 1 'Make it 1 for debugging purposes
hwnd = Me.hwnd

Call GetLayeredWindowAttributes(hwnd, vbNull, byteAlpha, vbNull)  'use vbNull for variables you don't need

Debug.Print = GetLastError() & " " & byteAlpha


Debug.Print shows that GetLastError() returns 998, which the MSDN says is ERROR_NOACCESS (Invalid access to memory location.)
byteAlpha is still the same value as before (1).

I can call the GetLayeredWindowAttributes in Dev-C++ on the same computer and it works fine.

Does anyone have any idea on how to call it from VB6 in Vista?

Aaraggornn
Newbie Poster
7 posts since May 2007
Reputation Points: 10
Solved Threads: 1
 

I was experimenting and found out the solution. You need to declare it without ByVal like this (except for hwnd as that is not a returned value):

Private Declare Function GetLayeredWindowAttributes Lib "user32.dll" (ByVal hwnd As Long, crKey As Long, bAlpha As Byte, dwFlags As Long) As Boolean


This works now.

Aaraggornn
Newbie Poster
7 posts since May 2007
Reputation Points: 10
Solved Threads: 1
 

HI,

if that solution not works try this one

goto control panel-->user accounts-->User Access control

disable the UAC(Unchek the checkbox)
it will prompt for restart,


restart and try your code,


With regards
Venktramasamy SN

venkatramasamy
Junior Poster in Training
71 posts since Aug 2007
Reputation Points: 12
Solved Threads: 12
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You