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

  • SEARCH
  • Home
  • 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 6779607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:24:19+00:00 2026-05-26T16:24:19+00:00

I have a old VB6 project.Now I migrating it in VB.Net on vs2008 and

  • 0

I have a old VB6 project.Now I migrating it in VB.Net on vs2008 and the solution platform now I have to use 64bit.In the old code the variable hContext was declared as Integer.

 Dim hContext As Integer

And used as:

Dim rc As Integer
dwScope = SCARD_SCOPE_USER
rc = SCardEstablishContext(dwScope, 0, 0, hContext)

When I debug the code the hContext create problem.
This is due to it define as a Integer(32bit).

Now the problem is “What datatype should I use for hContext”? I have also used different datatype like Long, ULong, IntPtr….

NOTE
When I debug the code the hcontext take 4byte address.but in 64bit I take hContext as IntPtr which is platform dependent,But it show only 1byte address. And I am not able to establish the connection.

  • 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-05-26T16:24:19+00:00Added an answer on May 26, 2026 at 4:24 pm

    I suspect the question is “what is the correct signature for SCardEstablishContext in a 64-bit project?”

    The C WinAPI signature is as follows:

    LONG WINAPI SCardEstablishContext(
      __in   DWORD dwScope,
      __in   LPCVOID pvReserved1,
      __in   LPCVOID pvReserved2,
      __out  LPSCARDCONTEXT phContext
    );
    

    Pointer types (“LP…”) should be IntPtr and LONG/DWORD types should map to Integer — this will be correct for a WinAPI call in either a 32-bit or a 64-bit build. (In some cases it is nice to specify a managed structure type instead of IntPtr and let the .NET interoperability/pinvoke automatically marshal everything.)

    pinvoke.net is sometimes helpful — see pinvoke.net: SCardEstablishConnection and *note how the VB.NET signature at top is wrong — but care needs to be taken because definitions are sometimes incorrect and/or incomplete 😉

    The correct pinvoke signature, for an opaque context value, is:

    <DllImport("winscard.dll", SetLastError:=True)>
    Public Shared Function SCardEstablishContext(
        dwScope as Integer,
        pvReserved1 as IntPtr,
        pvReserved2 as IntPtr,
        <out>() phContext as IntPtr) As Integer
    End Function
    

    Happy coding.

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

Sidebar

Related Questions

I have a Qt/C++ project and an old VB6 project. The user base might
I have some old code (an old but still maintained VB6 application) that from
I have a fairly old project in vb6. And when I am trying to
we have recently upgraded an old VB6 windows app to C# .NET 4.0. I
We have old .net 1.1 project that is using a third party component. Aparently
I have old code that uses size_t which IIRC comes from cstring.h. On OS
I'm working on a very old project (2000) in VB6 which was modernized and
We have very old VB6 applications connecting to a Sybase database. Today they are
I have an old VB6 app which I'm still trying to support. A few
I'm currently rewriting an old VB6 program in C# in the .Net Framework 2.0

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.