Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. remove this ambiguity?

remove this ambiguity?

Scheduled Pinned Locked Moved Managed C++/CLI
c++comhelptutorialquestion
2 Posts 2 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    imran_rafique
    wrote on last edited by
    #1

    please tell how to remove this error ? when i exceute these lines Process tmpProcess; .. IntPtr hWnd=tmpProcess->Handle; System::IntPtr::op_Explicit(hWnd); //***************************************************** last line recive following error plz tell how to remove this ambiguity ? //*********************************** errorr is that send_recive_messages.cpp(48) : error C2668: 'System::IntPtr::op_Explicit' : ambiguous call to overloaded function d:\final project\Copy (3) of Windows_processes_hwnd\hwnd_managment\Stdafx.h(7): could be '__int64 System::IntPtr::op_Explicit(System::IntPtr)' d:\final project\Copy (3) of Windows_processes_hwnd\hwnd_managment\Stdafx.h(7): or 'int System::IntPtr::op_Explicit(System::IntPtr)' d:\final project\Copy (3) of Windows_processes_hwnd\hwnd_managment\Stdafx.h(7): or 'void *System::IntPtr::op_Explicit(System::IntPtr)' r00d0034@yahoo.com

    N 1 Reply Last reply
    0
    • I imran_rafique

      please tell how to remove this error ? when i exceute these lines Process tmpProcess; .. IntPtr hWnd=tmpProcess->Handle; System::IntPtr::op_Explicit(hWnd); //***************************************************** last line recive following error plz tell how to remove this ambiguity ? //*********************************** errorr is that send_recive_messages.cpp(48) : error C2668: 'System::IntPtr::op_Explicit' : ambiguous call to overloaded function d:\final project\Copy (3) of Windows_processes_hwnd\hwnd_managment\Stdafx.h(7): could be '__int64 System::IntPtr::op_Explicit(System::IntPtr)' d:\final project\Copy (3) of Windows_processes_hwnd\hwnd_managment\Stdafx.h(7): or 'int System::IntPtr::op_Explicit(System::IntPtr)' d:\final project\Copy (3) of Windows_processes_hwnd\hwnd_managment\Stdafx.h(7): or 'void *System::IntPtr::op_Explicit(System::IntPtr)' r00d0034@yahoo.com

      N Offline
      N Offline
      Nick Hodapp
      wrote on last edited by
      #2

      First of all, your variable naming implies that you are expecting tmpProcess->Handle to be a window handle. It is not; it is a process handle. Also, in C++, since Process is a reference type, it must be declared as a pointer:

      System::Diagnostics::Process* tmpProcess;

      The op_Explicit() operator you are calling exists for implicit casting purposes in C# -- convert the value held by the IntPtr to an __int64, int, or void*. (Recall that the native size of the value of an IntPtr is determined by the platform; on 32bit hardware it is 32 bits, would be 64bits on 64bit hardware). I'll ask around, but I think in C++ it is impossible to disambiguate this function-call because in C++ it is illegal to overload a function based soely on its return type, which is what is happening here. You can get the same functionality by calling one of the conversion members: IntPtr::ToInt32(), IntPtr::ToInt64(), or IntPtr::ToPointer():

      long l = hWnd->ToInt32();

      This posting is provided “AS IS” with no warranties, and confers no rights. You assume all risk for your use. © 2001 Microsoft Corporation. All rights reserved.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups