Solved

(35 pts) CopyCursor API missing - User32.dll

Posted on 2000-05-15
10
1,067 Views
Last Modified: 2008-03-17
I want to use the CopyCursor Windows API which is documented in the WinSDK and Microsoft MSDN to change an Icon to a Cursor.  I found the declaration for this API in the VB 5 and VB 6 API Viewer.  It's declared as follows:

Public Declare Function CopyCursor Lib "user32" Alias "CopyCursor" (ByVal hcur As Long) As Long

I put it into my code and it came back with the following error:

Error Number = 453
Error Description = Can't find DLL entry point CopyCursor in user32

After getting this error, I looked in the WINUSER.H header file for the Windows API and it's there.  I looked at the exported functions in the USER32.DLL by using Dependency Walker and it did not show that the CopyCursor API was exported.  It did have the CopyIcon API exported, but that's now what I need.

The version of USER32.DLL that I'm using is : 4.00.950

--------------------

Can anyone tell me why that function is documented, and can be found in the API Viewer but can't be used because USER32.DLL doesn't export it?

Is there another API I can use to do this?

Is there another way to do this without the Windows API?

--------------------

HATCHET

0
Comment
Question by:HATCHET
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 3

Author Comment

by:HATCHET
Comment Utility
I found an alternate Windows API that does the same thing.  Here's the Visual Basic declaration for it (not found in the API Viewer), and the documentation on it from the MSDN Online Library:

Public Declare Function OleIconToCursor Lib "OLEPRO32.DLL" (ByVal hinstExe As Long, ByVal hIcon As Long) As Long


----------------------------------------

OleIconToCursor

Converts an icon to a cursor. For Win32 applications, this function calls the Win32 function CopyCursor(hIcon).

STDAPI OleIconToCursor(
  HINSTANCE hinstExe,  //Ignored in Win32
  HICON hIcon          //Handle to the icon
);
 

Parameters

hinstExe
     [in] Ignored in Win32.
hIcon
     [in] Handle to the icon to be converted to a cursor.

Remarks

The return value is an HCURSOR for the new cursor object. The caller is responsible for deleting this cursor with the Win32
function DestroyCursor. If the conversion could not be completed, the return value is NULL.

Requirements

  Windows NT/2000: Requires Windows NT 4.0 or later.
  Windows 95/98: Requires Windows 95 or later.
  Windows CE: Unsupported.
  Header: Declared in olectl.h.
  Library: Included as a resource in olepro32.dll.
0
 

Expert Comment

by:AZWolf7
Comment Utility
Looking at the DLL database at Microsoft, VB5 uses version 4.0.1381.3, which is several versions newer than the one you have on the system. I checked the MSDN, and you are right, it should be in there. However, it would not surprise me if they assume the end user will have the more recent version. I looked at the Dan Appleman book for VB4, and it is not a documented API call there, but that doesn't necessarily mean anything since he only documents a very small portion.

My guess is that the version of user32 required is actually 4.0.1381.3, the minimum for VB5 to run (obviously VB6 would need this or more recent), or one of the service packs. The highest version now is 5.0.2180.1.
0
 
LVL 27

Expert Comment

by:Ark
Comment Utility
Hi
About your first question - CopyIcon can be used to copy cursors on Win32, thus Win32 does not support the Win16 CopyCursor function. So user32 hasn't CopyCursor function, but user has.

Cheers
0
 

Expert Comment

by:monteh
Comment Utility
Nothing like backwards compatibility eh?

Use CopyIcon, it works the same on cursors.

Private Declare Function CopyIcon Lib "user32" (ByVal hIcon As Long) As Long
0
 
LVL 27

Expert Comment

by:Ark
Comment Utility
Hi, monteh
Welcome to EE
Take a look at my previous comment - is there any difference with your proposed answer?
HATCHET, it seems that it's one more MS error. I also check user C header, and on-line SDK - and find this function in both places. But user32.dll hasn't this function (though user.exe has) - this is 16-bit function. But I can not understand, what exatly do you want to do?  Why do you need to duplicate cursor? If you already have hCur, use selectobject API to select this cursor into DC and then play with this DC.
Cheers
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 3

Author Comment

by:HATCHET
Comment Utility
AZWolf7,

Can you send me your USER32.DLL?  Mine is obviously very outdated.  I'm using Windows 95B.  Is that your operating system?  If not, don't bother sending it... I need the same to match the OS.  Is there a web site that I can get that DLL from?

I took a look at my KERNEL32.DLL too and it's outdated as well : v4.00.1111

I took a look at my GDI32.DLL too... it's also outdated : v4.00.950

There's got to be a way to update these DLL's... either from Microsoft, or some site out there that has them.  If anyone has Windows 95B and has newer files, send them to HATCHET1998@hotmail.com

-------------------------------------

Ark,

I tried using CopyIcon, but I want to change an Icon to a Cursor... READ THE QUESTION.

Thanks for posting though.

-------------------------------------

monteh,

Read the question and don't take other people's comments and post them as the answer (especially when those comments are wrong).

-------------------------------------

Ark,

As the question states... I want to change an ICON to a CURSOR... CopyIcon doesn't work... though the Windows API does use a C++ implementation of the CopyIcon function to change it somehow to a Cursor.  Any idea HOW?   =)

-------------------------------------

HATCHET
0
 

Expert Comment

by:monteh
Comment Utility
Ark: looks the same. That's what happens when you sit on your browser for 1/2 hr.

sorry for the mispost...

0
 
LVL 27

Expert Comment

by:Ark
Comment Utility
Hello, HATCHET.
But you have already answered to your question yourself. Use OleIconToCursor function to convert hIcon to hCursor. But for Win32 icon and cursor are almost the same things with only difference -cursor has info about hotspot but icon has. You can use icon instead cursor in any win32 app (including VB), hotspot will be at the center of icon.
One more question: what do you have as start point (*.ico file, hIcon from one of ExtractIcon... functions) and what do you want to get at the end point (hCursor or *.cur file)?
Cheers


0
 

Accepted Solution

by:
HATCHET1 earned 35 total points
Comment Utility
I'm going to close this question because I found the answer on my own and keeping it open is going nowhere.

The answer is either use the "OleIconToCursor" function from OLEPRO32.DLL, or get an up-to-date version of the USER32.DLL to have access to the "CopyCursor" function... which IS there, but for some reason is not included in early versions of the USER32.DLL.    I can confidently assume that Micorsoft GOOFED UP on that one.

HATCHET
0
 
LVL 3

Author Comment

by:HATCHET
Comment Utility
Answer accepted
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now