Problem using DLL Function imports in VS .NET 2010 C++

This is a discussion on Problem using DLL Function imports in VS .NET 2010 C++ within the C++ Programming forums, part of the General Programming Boards category; Hello, I'm having an issue with the syntax for DLL function imports in VS C++ 2010. The following lines are ...

  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    10

    Problem using DLL Function imports in VS .NET 2010 C++

    Hello, I'm having an issue with the syntax for DLL function imports in VS C++ 2010. The following lines are in the .NET 2003 format:

    Code:
    [DllImport("gxsw.dll", EntryPoint="Gx6315Initialize", CharSet=CharSet::Ansi)]
    extern void __cdecl Gx6315Initialize(int slot, int __gc* pHandle, short __gc* pnStatus);
    To convert it to .NET 2010 syntax, I came up with this:

    Code:
    [DllImport("gxsw.dll", EntryPoint="Gx6315Initialize", CharSet=CharSet::Ansi)]
    extern void __cdecl Gx6315Initialize(__int16 slot, __int16 __gc* pHandle, __int16 __gc* pnStatus);
    Can someone who's adept at the .NET 210 syntax tell me if this is correct? If not, what isn't? This is the first time I'm coding in .NET 2010, and could really use some pointers.

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    This does not look like C++. AFAIK the import/export method has not changed in VS2010 and I googled and could not verify it had changed to the syntax you have shown. This looks like a mixture between the C# P/invoke import syntax and C++.

  3. #3
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    Importing stuff has not changed in 2010 as far as I know. However, 2010 is no longer Managed C++ but C++/CLI. Your "__gc*" is probably obsolete and should be replaced by a "^". But that's a change that will affect your whole code, not just this single line.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BEST IDEA in 2010
    By KIBO in forum General Discussions
    Replies: 21
    Last Post: 12-14-2010, 10:21 AM
  2. 20/10/2010 20:10
    By Salem in forum General Discussions
    Replies: 10
    Last Post: 10-21-2010, 10:46 AM
  3. Visual C++ 2010 problem.
    By Kitt3n in forum C++ Programming
    Replies: 21
    Last Post: 07-27-2010, 01:01 PM
  4. visualC++ 2010
    By KIBO in forum Windows Programming
    Replies: 1
    Last Post: 10-13-2009, 01:44 AM
  5. Windows 7 RC, Visual Studio 2010 Beta, Office 2010 beta, anyone in?
    By indigo0086 in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 05-20-2009, 01:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21