Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 95403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:39:10+00:00 2026-05-10T23:39:10+00:00

What is the proper way to cast from an ‘OLE_HANDLE’ to an ‘HICON’ for

  • 0

What is the proper way to cast from an ‘OLE_HANDLE’ to an ‘HICON’ for an x64 target build?

In particular with a normal C-Style cast, I get this warning when compiling with an x64 config:

warning C4312: ‘type cast’ : conversion from ‘OLE_HANDLE’ to ‘HICON’ of greater size

Here is the offending code:

imgList.Add((HICON)ohIcon); 

The above code works fine for me, but I want to get rid of the warning when building for x64.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T23:39:10+00:00Added an answer on May 10, 2026 at 11:39 pm

    The H gives it away, in this case the library code has created a distinct type to give you a little more type safety (in the days of old C APIs).

    They are actually both HANDLEs, which is a kernel object that doesn’t really care what the resource is, just that you have a ‘handle’ to it. Remember the API is a C one, so use C style casts, and when you come to delete it, use DeleteObject().

    edit: 64 bits eh… the problem’s because MS updated Handles to be 64 bits, but left the OLE stuff alone. Fortunately, all they did was pad the extra bits with zeros.

    Try using the LongToHandle conversion routines and see the MIDL porting guide – scroll about halfway down to the ‘USER and GDI handles are sign extended 32b values’ section.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 66k
  • Answers 66k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer MOD_ALT, MOD_CONTROL, etc don't have any relationship to the keycodes… May 11, 2026 at 11:28 am
  • added an answer Erm, what? :-) w3wp is just the worker process for… May 11, 2026 at 11:28 am
  • added an answer There is a struts-config.xml configuration that allows you to define… May 11, 2026 at 11:28 am

Related Questions

What is the proper way to cast from an 'OLE_HANDLE' to an 'HICON' for
What is the proper way to minimize a WinForms app to the system tray?
What is the proper way to terminate a Swing application from the code, and
what is the proper way to scale an SDL Surface? I found one explanation
What is the proper way to load a ListBox in C# .NET 2.0 Winforms?
What is the proper way to install Hibernate Tools in Eclipse as a plugin?
What is the most proper way to sending email of minimal 1000 or more
What is the best way of working with calculated fields of Propel objects? Say
What is the proper technique to have ThreadA signal ThreadB of some event, without
What is the proper place to explain error handling in a try-catch statement? It

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.