473,396 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

MIDL2139 Error


Hi, I get the following error when I try to compile my c++ code which
has a segment like:

__interface IObject1 : IDispatch
{
HRESULT COMTry([in]HDEVINFO DeviceInfoSet,[in]MYSTRUCT *ptr,[in]BSTR
*bstr);
};

and its implementation in a derived class as:

HRESULT COMTry(HDEVINFO vptr, MYSTRUCT *ptr,BSTR *bstr)
{
return S_OK;
}

error MIDL2139 : type of the parameter cannot derive from void or void
* : [ Type 'HDEVINFO' ( Parameter 'DeviceInfoSet' ) ]

Actually DeviceInfoSet is a variable of type HDEVINFO(HDEVINFO defined
as PVOID in SetUpAPI.h). Any help would be appreciated.

Thanks in advance.
Kris.

--
tropictroop
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

Nov 17 '05 #1
1 2825
"tropictroop" <tr****************@mail.codecomments.com> wrote:
__interface IObject1 : IDispatch
{
HRESULT COMTry([in]HDEVINFO DeviceInfoSet,[in]MYSTRUCT *ptr,[in]BSTR
*bstr);
};

error MIDL2139 : type of the parameter cannot derive from void or void
* : [ Type 'HDEVINFO' ( Parameter 'DeviceInfoSet' ) ]

Actually DeviceInfoSet is a variable of type HDEVINFO(HDEVINFO defined
as PVOID in SetUpAPI.h). Any help would be appreciated.

According to
http://msdn.microsoft.com/library/de...ler_errors.asp :

"MIDL2139: type of the parameter cannot derive from void or void*
MIDL is a strongly typed language. All parameters transmitted over the
network must be derived from one of the MIDL base types. MIDL does not
support void as a base type. You must change the declaration to a valid MIDL
type."

In short, you can't pass HDEVINFO objects to an MIDL interface, because
they're not typesafe. Instead, use SetupDiEnumDeviceInfo to get access to
the device's instance ID DevInst, pass this through the MIDL interface, and
use SetupDiOpenDeviceInfo to regain access to it on the other side. I
haven't tried this - you might have to pass other information from
PSP_DEVINFO_DATA as well and/or use other device info functions.

More generally, whenever you have to pass an object which is not
MIDL-compliant, try instead to obtain a unique identifier for that object in
the form of an integer or string that you can use to find it again in the
called function. I hope this helps.
--
Derrick Coetzee, Microsoft Speech Server developer
This posting is provided "AS IS" with no warranties, and confers no rights.
Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
5
by: Tony Wright | last post by:
Hi, I am having a problem installing an msi for a web site. The error message I am getting is: "The specified path 'http://mipdev05/features/Fas2' is unavailable. The Internet Information...
1
by: Aravind | last post by:
we have two files: 1. rc4.c (defines one function "create_pin()") 2. MyImpl.c(calling the function "create_pin()"),This implements JNI method. 1.When I am trying to create .dll file with one...
1
by: yanwan | last post by:
I met this problem in executing a c++ project in visual studio. Does anyone have suggestions to resolve "error lnk 2001"? --------------------Configuration: reconstruction - Win32...
5
by: Enos Meroka | last post by:
Hallo, I am a student doing my project in the university.. I have been trying to compile the program using HP -UX aCC compiler, however I keep on getting the following errors. ...
13
by: deko | last post by:
I use this convention frequently: Exit_Here: Exit Sub HandleErr: Select Case Err.Number Case 3163 Resume Next Case 3376 Resume Next
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.