Error 998 in VB6 on Vista Home Premium

Reply

Join Date: May 2007
Posts: 7
Reputation: Aaraggornn is an unknown quantity at this point 
Solved Threads: 1
Aaraggornn Aaraggornn is offline Offline
Newbie Poster

Error 998 in VB6 on Vista Home Premium

 
0
  #1
Jan 9th, 2008
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:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. 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:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim byteAlpha As Byte, hwnd As Long
  2.  
  3. byteAlpha = 1 'Make it 1 for debugging purposes
  4. hwnd = Me.hwnd
  5.  
  6. Call GetLayeredWindowAttributes(hwnd, vbNull, byteAlpha, vbNull) 'use vbNull for variables you don't need
  7.  
  8. 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?
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 7
Reputation: Aaraggornn is an unknown quantity at this point 
Solved Threads: 1
Aaraggornn Aaraggornn is offline Offline
Newbie Poster

Re: Error 998 in VB6 on Vista Home Premium

 
0
  #2
Jan 9th, 2008
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):
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. 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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 71
Reputation: venkatramasamy is an unknown quantity at this point 
Solved Threads: 12
venkatramasamy's Avatar
venkatramasamy venkatramasamy is offline Offline
Junior Poster in Training

Re: Error 998 in VB6 on Vista Home Premium

 
0
  #3
Jan 9th, 2008
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC