Jump to content


Help---- VC# to VC++ .Net --- Help


  • You cannot reply to this topic
1 reply to this topic

#1 bxchan

    New Member

  • Members
  • Pip
  • 1 posts

Posted 06 November 2006 - 01:40 AM

Hi, i am newbie on VC++ .Net.
i face a problem to convert VC# code to VC++ .Net
--------------------------------------------------------------------------
here is VC# code (Working)
--------------------------------------------------------------------------
class Class1
{
[DllImport("setupapi.dll")]//
public static extern Boolean
SetupDiClassGuidsFromNameA(string ClassN, ref Guid guids, UInt32 ClassNameSize, ref UInt32 ReqSize);

[STAThread]
static void Main(string[] args)
{
UInt32 RequiredSize = 0;
Guid[] guids=new Guid[1];

bool res=SetupDiClassGuidsFromNameA("DiskDrive",ref guids[0],RequiredSize, ref RequiredSize);
}

--------------------------------------------------------------------------
Here is the code that i convert to VC++(no working)
--------------------------------------------------------------------------

#include "stdafx.h"

#using <mscorlib.dll>
using namespace System::Runtime::InteropServices;
using namespace System;
using namespace System::Text;

[DllImportAttribute("setupapi.dll", CharSet=CharSet::Auto)]
extern "C" Boolean
SetupDiClassGuidsFromNameA(String *ClassN, Guid* guids, UInt32 ClassNameSize, unsigned int *ReqSize);

int _tmain()
{
UInt32 RequiredSize = 0;
Guid guids = new Guid[1];
SetupDiClassGuidsFromNameA(S"DiskDrive", guids[0], RequiredSize, &RequiredSize);
Console::WriteLine(RequiredSize.ToString());
return 0;
}
--------------------------------------------------------------------------The Correct behaviour is the RequiredSize should be Greater than 0, but the code that i have convert the RequiredSize always return 0.:wallbash:

can any one help me.

Thank you.

Regards,
bxchan

#2 Skavenger

    New Member

  • Members
  • PipPip
  • 17 posts

Posted 28 November 2006 - 10:50 AM

Because the 3rd parameter your passing into SetupDiClassGuidsFromNameA()
should be the "ClassGuidListSize" your passing in 0.

- Skavenger.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users