Solved

(35 pts) CopyCursor API missing - User32.dll

Posted on 2000-05-15
10
1,088 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
ID: 2812594
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
ID: 2812626
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
ID: 2812948
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Expert Comment

by:monteh
ID: 2813018
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
ID: 2813826
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
 
LVL 3

Author Comment

by:HATCHET
ID: 2814121
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
ID: 2814303
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
ID: 2815204
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
ID: 2845397
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
ID: 2845407
Answer accepted
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 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