I have an application in vb which encountes this two errors:

cannot find dlllentrypoint:setLayered.window attributes in user32.dll

and 2nd

runtime error 91: Object variable or block variable not set.

when i run it on windows 98 , but it works fine with windows XP..

Can any one please help me in this..so that i can run it on both OS..
And also make clear this doubts..


Recommended Answers

All 4 Replies

runtime error 91:
somewhere in your code you probably
didn't use SET , example:

a = ....

instead of:

The error: cannot find dlllentrypoint:setLayered.window attributes in user32.dll is caused in Windows 98 because Windows 98 cannot make windows transparent (the SetLayeredWindowAttribute API call is used to make windows or forms transparent).
Windows XP supports transparent windows so it works there.
The only way to make it work in Windows 98 is to remove or comment out all references to the SetLayeredWindowAttributes API call or code it so that it only runs that code if the operating system is Windows 2000/XP/Vista (I'm not sure how to do that right at the moment, but I can find out if you want).

Thank you so much for ur reply..
And yes, if you can find it for me i would be a great help.
And also can u tell me which are those references to the SetLayeredWindowAttributes API call or code ??? Any example that u can give me.

Thank u.

Note: All this code should work in Microsoft Visual Basic 5 or 6. It won't work if you are using the .Net version.

To code it so that the SetLayeredWindowAttributes function is only called if you are running Windows NT and higher you would need to add the following code. This declares the SetLayeredWindowAttributes function, the OSVERSIONINFO type which is used to store the information and the constants used to determine the OS type. It also declares the variable we will use to store whether we can use the function.

In the declaration section of the form you would add (the declaration section is usually up the top of the code window):

Private Declare Function GetVersionEx Lib "kernel32.dll" Alias "GetVersionExA" (ByRef lpVersionInformation As OSVERSIONINFO) As Long
    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128 ' Maintenance string for PSS usage
End Type
Private Const VER_PLATFORM_WIN32_NT As Long = 2
Private Const VER_PLATFORM_WIN32_WINDOWS As Long = 1
Private Const VER_PLATFORM_WIN32s As Long = 0
Dim CanUseLayered as Boolean

In the Form_Load subroutine (which is usually what comes up when you double click the form in the editor) you would add:

OSVersion.dwOSVersionInfoSize = Len(OSVersion)
Call GetVersionEx(OSVersion)
If OSVersion.dwPlatformId >= VER_PLATFORM_WIN32_NT Then
CanUseLayered = True
CanUseLayered = False
End If

The first three lines are used to retrieve the OS version.
The other lines work out if you are using Windows 2000 or higher. If you are it sets CanUseLayered to True otherwise it sets it to False.

You would now need to find all the SetLayeredWindowAttributes calls in your code. They could look something like this:

SetLayeredWindowAttributes hwnd, 0, 255, LWA_ALPHA
[I]variable[/I] = SetLayeredWindowAttributes(hwnd, 0, 50, LWA_ALPHA)

SetLayeredWindowAttributes has 4 different parts.
The first one, hwnd, is the handle to the form that is being made transparent, this could look like Form1.Hwnd or it could be any variable.
The second, 0, is the transparent colour of the window but is not used.
The third, 255, is the amount of transparency you want, 0 is completly transparent and 255 is completly opaque. This could also be a variable.
The fourth, LWA_ALPHA, is telling it that you want to make it transparent. This could also be the number 2. If it is LWA_COLORKEY or the number 1 then the second option, the transparent color, is used and not the level of tranparency.

You would need to add before each SetLayeredWindowAttributes call the following line: If CanUseLayered = True Then After each SetLayeredWindowAttributes call you would add: End If These just make it that if CanUseLayered is True then it will call the SetLayeredWindowAttributes function. If it is not True then it won't call the function.

It would look something like this:

If CanUseLayered = True Then
SetLayeredWindowAttributes hwnd, 0, 50, LWA_ALPHA
End If

If you only wanted to comment out the SetLayeredWindowAttributes calls you would just put an apostrophe (') before each line that calls the function.

I hope this helps you.:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.