Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I have some experience working in visual C#. lately i wanted to identify keyboard and joystick inputs, therefore I chose to implement a source code with windows raw input API. Since visual studio does not contain the struct RAWINPUTDEVICE i chose to go with visual C++. when I tried the sample code provided in MSDN following type of errors pop up in servprov.h file. below is the source code I used.
C++
// This is the main DLL file.
//test.cpp
#include "stdafx.h"

#include "rawInputTestCPP.h"
#include <Windows.h>


void main(){
	RAWINPUTDEVICE Rid[4];
        
	Rid[0].usUsagePage = 0x01; 
	Rid[0].usUsage = 0x05; 
	Rid[0].dwFlags = 0;                 // adds game pad
	Rid[0].hwndTarget = 0;

	Rid[1].usUsagePage = 0x01; 
	Rid[1].usUsage = 0x04; 
	Rid[1].dwFlags = 0;                 // adds joystick
	Rid[1].hwndTarget = 0;

	Rid[2].usUsagePage = 0x0B; 
	Rid[2].usUsage = 0x00; 
	Rid[2].dwFlags = RIDEV_PAGEONLY;    //adds devices from telephony page
	Rid[2].hwndTarget = 0;

	Rid[3].usUsagePage = 0x0B; 
	Rid[3].usUsage = 0x02; 
	Rid[3].dwFlags = RIDEV_EXCLUDE;     //excludes answering machines
	Rid[3].hwndTarget = 0;

	if (RegisterRawInputDevices(Rid, 4, sizeof(Rid[0])) == FALSE) {
		//registration failed. Call GetLastError for the cause of the error.
	}
}


errors popped up are as follows

Error 1 error C2872: 'IServiceProvider' : ambiguous symbol c:\program files (x86)\microsoft sdks\windows\v7.0a\include\servprov.h 96 1

Error 2 error C3699: '*' : cannot use this indirection on type 'IServiceProvider' c:\program files (x86)\microsoft sdks\windows\v7.0a\include\servprov.h 96 1

Error 3 error C2371: 'IServiceProvider' : redefinition; different basic types c:\program files (x86)\microsoft sdks\windows\v7.0a\include\servprov.h 103 1

Error 4 error C2872: 'IServiceProvider' : ambiguous symbol c:\program files (x86)\microsoft sdks\windows\v7.0a\include\servprov.h 120 1

Error 5 error C2872: 'IServiceProvider' : ambiguous symbol c:\program files (x86)\microsoft sdks\windows\v7.0a\include\servprov.h 241 1

Error 6 error C2872: 'IServiceProvider' : ambiguous symbol c:\program files (x86)\microsoft sdks\windows\v7.0a\include\servprov.h 251 1

Error 7 error C2872: 'IServiceProvider' : ambiguous symbol C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\urlmon.h 6459 1

Error 8 error C2872: 'IServiceProvider' : ambiguous symbol C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\urlmon.h 6461 1

any idea why these errors pop up?
Posted

1 solution

if you carefully really the messages you find it yourself:

Error 1 error C2872: 'IServiceProvider' : ambiguous symbol c:\program files (x86)\microsoft sdks\windows\v7.0a\include\servprov.h 96

Error 8 error C2872: 'IServiceProvider' : ambiguous symbol C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\urlmon.h 6461

you need to look in both headers why they expose the interface. A missing define of the correct window version or namespace hustle.

interesting links
MSDN forum
Ambiguous References in .net
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900