תרגום מc# ל vb
אני כותב די בסדר בvb עכשיו מצאתי באינטרנט משהו באינרנט שאני צריך ב c# וניסיתי לתרגם איפשהו יש לי טעות בבקשה תעזרו לי.. c# המקור(עובד):
אני כותב די בסדר בvb עכשיו מצאתי באינטרנט משהו באינרנט שאני צריך ב c# וניסיתי לתרגם איפשהו יש לי טעות בבקשה תעזרו לי.. c# המקור(עובד):
[DllImport("kernel32.dll")] private static extern long GetVolumeInformation(string PathName, StringBuilder VolumeNameBuffer, UInt32 VolumeNameSize, ref UInt32 VolumeSerialNumber, ref UInt32 MaximumComponentLength, ref UInt32 FileSystemFlags, StringBuilder FileSystemNameBuffer, UInt32 FileSystemNameSize); public string GetVolumeSerial(string strDriveLetter) { uint serNum = 0; uint maxCompLen = 0; StringBuilder VolLabel = new StringBuilder(256); // Label UInt32 VolFlags = new UInt32(); StringBuilder FSName = new StringBuilder(256); // File System Name strDriveLetter+=":\\"; long Ret = GetVolumeInformation(strDriveLetter, VolLabel, (UInt32)VolLabel.Capacity, ref serNum, ref maxCompLen, ref VolFlags, FSName, (UInt32)FSName.Capacity); return Convert.ToString(serNum); }
הניסיון הלא מוצלח שלי בvb:Declare Auto Function GetVolumeInformation Lib "kernel32.dll" (ByVal path As String, ByVal VolumeNameBuffer As System.Text.StringBuilder, ByVal VolumeNameSize As Int32, ByVal VolumeSerialNumber As Int32, ByVal MaximumComponentLength As Int32, ByVal FileSystemFlags As Int32, ByVal FileSystemNameBuffer As System.Text.StringBuilder, ByVal FileSystemNameSize As Int32) As Long Dim sernum As Int32 = 0 Dim maxCompLen As Int32 = 0 Dim VolLabel As New System.Text.StringBuilder(256) Dim VolFlags As New Int32 Dim FSName As New System.Text.StringBuilder(256) Dim drvlet As String = "C:\\" Dim ret As Long ret = GetVolumeInformation(drvlet, VolLabel, 256, sernum, maxCompLen, VolFlags, FSName, 256) MsgBox(sernum)
הבעיה היא שהקוד עובר כאילו שgetvolumeinformtion לא הייתה..