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 8296799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:09:29+00:00 2026-06-08T15:09:29+00:00

I ported my appliction from Windows 7 32-bit to Windows 7 64-bit. I find

  • 0

I ported my appliction from Windows 7 32-bit to Windows 7 64-bit. I find that the API function OpenSemaphore is always returning zero. This call works well in 32-bit Windows, but not in 64-bit Windows.

When I call GetLastError(), it returns 2.

Also I replaced my OpenSemaphore with the CreateSemaphore function and my application works fine, but I am still confused about why the OpenSemaphore function is failing in 64-bit code.

Can anyone who knows something about this issue please clarify?

  • 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. Editorial Team
    Editorial Team
    2026-06-08T15:09:30+00:00Added an answer on June 8, 2026 at 3:09 pm

    Checking the error code when a function fails is a good first step, but you need to make sure you understand what that error code means. The possible error codes returned by the GetLastError function are documented here.

    In this case, you say that the error code is 2. That corresponds to ERROR_FILE_NOT_FOUND, which means

    The system cannot find the file specified.

    You are probably asking yourself: file, what file? Yeah, sometimes understanding the error codes requires a little bit of creative thought. So let’s think about it: what could “file not found” possibly mean with regard to the OpenSemaphore function? Well, one of the parameters is a string that specifies the name of the semaphore to be opened. That’s sort of like a file, right? Close enough to be a good lead!

    Chances are, then, the value you’re specifying for the lpName parameter does not correspond to a valid semaphore. The first thing I’d normally check is the case of the string—the comparisons made with the lpName value are case-sensitive. But since you said it used to work in a 32-bit application, that’s probably not what’s wrong here.

    The 32-to-64-bit transition does give us another clue, though. Remember that 32-bit and 64-bit applications are very different beasts and are not generally allowed to touch each other. It stands to reason, then, that a 64-bit application would be unable to use a semaphore created by a 32-bit application, and vice versa.

    Considering you said that it works if you call CreateSemaphore to create a new semaphore, that puts us well on our way to finding an answer. Chances are, the semaphore you’re trying to open with the call to the OpenSemaphore function is one created by a 32-bit process, and it therefore can’t be opened or used by a 64-bit process. (Remember, the documentation tells us that “The function succeeds only if some process has already created the semaphore by using the CreateSemaphore function”.) If you create a new semaphore in the 64-bit process, you can open and use it without a problem.

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

Sidebar

Related Questions

I am using a library that has been ported to Windows from Linux. The
I am debugging an application that I ported from Windows, to *nix, a little
I am re-engineering a windows application to be ported to web. One area that
I ported a little Haskell program I wrote from Mac to Windows. It's a
I have ported over some code from a Windows application to Monotouch. It is
I am using GetWindowRect from the windows API to get the bounds of a
I'm porting a complex algorithm from 32 Bit to 64 Bit that takes about
I have an AWT applet application that needs to be ported over to GWT.
My application is a rather well behaved Windows citizen, so when I ported it
In a legacy application (created in Delphi 6 under WinXP in 32-bit, recently ported

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.