[VB] C typedef omzetten naar VB Type

Pagina: 1
Acties:

  • WhiteDog
  • Registratie: Juni 2001
  • Laatst online: 21-05 21:05

WhiteDog

met zwarte hond

Topicstarter
Ik wil graag volgende typedef gebruiken in VB:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
typedef struct _DISK_PERFORMANCE {
  LARGE_INTEGER  BytesRead;
  LARGE_INTEGER  BytesWritten;
  LARGE_INTEGER  ReadTime;
  LARGE_INTEGER  WriteTime;
  LARGE_INTEGER  IdleTime;
  ULONG  ReadCount;
  ULONG  WriteCount;
  ULONG  QueueDepth;
  ULONG  SplitCount;
  LARGE_INTEGER  QueryTime;
  ULONG  StorageDeviceNumber;
  WCHAR  StorageManagerName[8];
} DISK_PERFORMANCE, *PDISK_PERFORMANCE;


ik heb er het volgende van gemaakt:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Public Type DISK_PERFORMANCE
  BytesRead As Currency
  BytesWritten As Currency
  ReadTime As Currency
  WriteTime As Currency
  IdleTime As Currency
  ReadCount As Long
  WriteCount  As Long
  QueueDepth  As Long
  SplitCount  As Long
  QueryTime As Currency
  StorageDeviceNumber As Long
  StorageManagerName(8) As String
End Type


maar dit werkt echter niet met volgende code:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
Public Function GetDiskPerformance(hDevice As Long) As DISK_PERFORMANCE
    
   Dim bytesReturned As Long
   Dim x As Long

   x = DeviceIoControl(hDevice, _
                        IOCTL_DISK_PERFORMANCE, _
                        ByVal 0&, _
                        0&, _
                        GetDiskPerformance, _
                        Len(GetDiskPerformance), _
                        bytesReturned, _
                        ByVal 0&)


Ik vermoed dat het probleem zit bij mijn type. Onderstaan de structdef staat "*PDISK_PERFORMANCE" en ik weet niet wat ik daarmee moet aanvangen in VB. Ook over de wchar ben ik niet helemaal zeker...

Microsoft Site met originele code:
http://msdn.microsoft.com...octl_disk_performance.asp

Iemand een idee waar ik de mist in ga?

  • Eelis
  • Registratie: Januari 2003
  • Laatst online: 21-02-2015
.

[ Voor 125% gewijzigd door Eelis op 18-02-2015 19:27 ]


  • WhiteDog
  • Registratie: Juni 2001
  • Laatst online: 21-05 21:05

WhiteDog

met zwarte hond

Topicstarter
Afgekeken van een ander stukje (werkende) code waar ik wel een vb-versie van vond:

code:
1
2
3
4
5
6
7
8
typedef struct _DISK_GEOMETRY {
LARGE_INTEGER Cylinders; 
MEDIA_TYPE MediaType;
DWORD TracksPerCylinder;
DWORD SectorsPerTrack;
DWORD BytesPerSector;
}
DISK_GEOMETRY;


code:
1
2
3
4
5
6
7
Public Type DISK_GEOMETRY
   Cylinders         As Currency  'LARGE_INTEGER (8 bytes)
   MediaType         As Long
   TracksPerCylinder As Long
   SectorsPerTrack   As Long
   BytesPerSector    As Long
End Type

  • Eelis
  • Registratie: Januari 2003
  • Laatst online: 21-02-2015
.

[ Voor 98% gewijzigd door Eelis op 18-02-2015 19:27 ]


  • WhiteDog
  • Registratie: Juni 2001
  • Laatst online: 21-05 21:05

WhiteDog

met zwarte hond

Topicstarter
Probleem opgelost:
WCHAR StorageManagerName[8];

word:

StorageManagerName(0 to 7) as integer

Verwijderd

Eelis schreef op 19 juni 2004 @ 18:04:
VB zal dan toch ook wel een normaal integer type van 8 bytes hebben?
Niet dus.

VB Integer = Word
VB Long = DWORD
Het zou wel erg achterlijk zijn als je er per sé Currency bij moet betrekken om zo'n type mapping te maken..
tsja

  • RayNbow
  • Registratie: Maart 2003
  • Laatst online: 08:16

RayNbow

Kirika <3

Zoeken op "visual basic LARGE_INTEGER" geeft:
 
Visual Basic 6:
1
2
3
4
Private Type LARGE_INTEGER
    lowpart As Long
    highpart As Long
End Type


edit:
Ik lees dus net ergens op een site dat Currency ook werkt... Het zijn 64 bits integers die door VB door 10000 worden gedeeld. Bah...

http://www.devx.com/vb2themax/Tip/18308

[ Voor 44% gewijzigd door RayNbow op 19-06-2004 23:56 ]

Ipsa Scientia Potestas Est
NNID: ShinNoNoir

Pagina: 1