Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / February 2005

Tip: Looking for answers? Try searching our database.

MIDL2139 Error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tropictroop - 01 Feb 2005 11:12 GMT
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.


Derrick Coetzee [MSFT] - 09 Feb 2005 17:47 GMT
> __interface IObject1 : IDispatch
> {
[quoted text clipped - 7 lines]
> 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/default.asp?url=/library/en-us/midl/midl/compi
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.
Signature

Derrick Coetzee, Microsoft Speech Server developer
This posting is provided "AS IS" with no warranties, and confers no rights.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.