|
hi all,
how can i read the serial number(not volume serial number) of hard disk (not disk drive) using vb.net, that will works on any windows version - WinME, Win2K, WinXP etc.
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
hi..,
namespace in : Imports System.Management
Public Function GetHardDiskSerial() As String
Dim mobjSearcher As New ManagementObjectSearcher _
("SELECT * FROM Win32_LogicalDisk WHERE Name = 'C:'")
For Each obj As ManagementObject In mobjSearcher.Get
Return obj("VolumeSerialNumber")
Next
Return "00000000000000"
End Function
thanks
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
hi,
Please Read carefully my question. I want to read Hard disk Serial number (not the volume serial number) which is run on all windows operating system.
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
Hi. I am trying to figure out how to write a select statement that will retrieve all entries that have a certian letter combination in. EG: If the user enters "a" it will retrieve all words starting with an "a". if he enters "ad" it will return all words stsrting with "ad" etc. Please advise
|
|
|
|
|
This is a very basic SQL question. I suggest picking up a beginners book on SQL Server and working through it.
All you have to do is add a WHERE clause using the LIKE operator:
SELECT field1, field2, fieldn, ... FROM table WHERE somefield LIKE 'ab%'
This will return all entries starting with the letters "ab" in some field you chose.
|
|
|
|
|
|
I'm calling a function in an unmanaged DLL. It is returning data as unsigned integers. I am using Marshal.ReadInt32() to marshal the data. I am getting an "Arithmetic overflow" exception when it trys to put the signed integer data into the managed unsigned integer variable:
Dim uiData as UInt32 = Marshal.ReadInt32(ipBuffer)
The exception only happens when the data has the most significant bit set (the "sign" bit). If Marshal.ReadUInt32() existed, obviously I would use that. Since it does not exist, I am marshaling the four bytes individually using Marshal.ReadByte() and constructing the unsigned integer. Is there a better way to do this?
|
|
|
|
|
VFaul wrote: Dim uiData as UInt32 = Marshal.ReadInt32(ipBuffer)
The exception only happens when the data has the most significant bit set (the "sign" bit). If Marshal.ReadUInt32() existed, obviously I would use that. Since it does not exist, I am marshaling the four bytes individually using Marshal.ReadByte() and constructing the unsigned integer. Is there a better way to do this?
No, not really. You're reading a four byte value as signed 32-bit integer (31 bits plus the sing bit), which means the number read can be a negative number, not positive. When the conversion to Unsigned is attempted, it can't convert a negative number, so you get the exception.
You can convert any number of bytes using the BitConverter class. You still need to read the four bytes into an array, but you can use the BitConverter.ToUInt32[^] method to do this, probably easier than you're doing it now.
|
|
|
|
|
Yes, I understand why the exception is occurring.
What baffles me is that there aren't unsigned marshaling methods: Marshal.ReadUInt16(), ReadUIn32(), and ReadUInt64()!? I'm being forced to do four ReadByte() calls when one call to ReadUInt32() is all I would need.
|
|
|
|
|
VFaul wrote: What baffles me is that there aren't unsigned marshaling methods: Marshal.ReadUInt16(), ReadUIn32(), and ReadUInt64()!? I'm being forced to do four ReadByte() calls when one call to ReadUInt32() is all I would need.
Yep. After looking at the code for the Marshal class, ReadInt32 method, it's sort of obvious why. That method has but a single line of code that calls a function, ND_RI4 , exported by mscoree.dll . This function reads a 4 byte value and returns an I4, or Int32. The only other exported functions that do this are:
ND_RI2 - Returns a 16-bit signed integer
ND_RI4 - Returns a 32-bit signed integer
ND_RI8 - Returns a 64-bit signed integer
and
ND_RU1 - Returns a single byte
There are counterpart functions that write values too, modeled after these "read" version. Sadly, it boils down to the CLR doesn't natively support what you want to do.
I also looked into the possibility of using Marshal.ReadIntPtr, which returns a processor width pointer. On any non-x64 version of Windows, this always maps to a 32-bit unsigned integer. But, there is no conversion supplied to go from an IntPtr to a UInt, only a conversion to Int32 exists.
|
|
|
|
|
Hi All,
I am doing Installaion build for a Vb Based Application.In the automation procedure of this,I need to change the version Compatability(In Project\Project Properties\Component) from outside.Means I need to change it programmatically.
Means in the automation procedural steps,it will take the project automatically,change the compatability and then save the project.
Can Anyone help me to solve this problem.......
Thanks In Advance,
Jeeva.
|
|
|
|
|
I am writing a VB 6 program that shd run on the network. A user has to login before using the program. Now, I want to prevent multiple user login using one user account. It shdn't allow or prevent a user to login whilst his/her account is in use. I am using MS SQL Server 2000 Database.
Please, can anyone help me with this? I would be very grateful if you could help me with this.
|
|
|
|
|
Once the user is logged in you can mark him/her as logged-in in your database. Whenever the user tries to log in you can check against the database if he is already logged-in or not.
"Legacy code" often differs from its suggested alternative by actually working and scaling.
—Bjarne Stroustrup
|
|
|
|
|
Hi. How do I change the title bar heading in a form dynamically in code?
|
|
|
|
|
use below statement in the code
form1.text=" Title Here!"
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
Hi. thanks.... I had to use me.text but thanks for the help.
|
|
|
|
|
I have a textfile which has lots of records.I want to open the text file in excel.I used the codings
below.What is the problem is all the columns in the textfile seems to be in the same column of
excel.
for example
i have records in text file as follows
name location Phno
lily chennai 234567
all the three columns are in the same column of excel.
Codings used
===========
Private Sub OpenTextFile()
Dim oExcel As New Excel.Application
oExcel = CreateObject("Excel.application")
oExcel.Visible = True
oExcel.Workbooks.Open("C:\sample\test.txt")
End Sub
|
|
|
|
|
Seems reasonable to me. Excel treats each line of text as cell.
Opening the file programatically does not invoke the import wizard you are probably used to. You will need to parse each line yourself if you want it split to discreet cells
|
|
|
|
|
There is an option in excel to set tab delimiters but i dont know how to set in codings.If anybody know how to do it pls help me.
modified on Wednesday, March 19, 2008 4:28 AM
|
|
|
|
|
AFAIK you have to do this manually during the load. I do not know if you can invoke the Excel tools (they need user interaction) when processing from code.
Your could use split and write each node to a cell manually
|
|
|
|
|
|
Hi.. I have a form that is accessed from a previous form by clicking either of 2 buttons. If for example button1 on form 1 is clicked it accesses a form2 with one set of details. If button 2 on form1 is clicked it accesses form2 but with a different set of details. I need to determine which button was clicked on form 1 so I can load the correct data on form 2. Please Assist
|
|
|
|
|
When you instantiate the form you can pass the button id or a value for each button to the sub new
in the calling form
oFrm = New frmPFElement(iID)
Constructor in the called form
Sub New(ByVal iID As Integer)<br />
<br />
' This call is required by the Windows Form Designer.<br />
InitializeComponent()<br />
<br />
' Add any initialization after the InitializeComponent() call.<br />
mvID = iID<br />
End Sub
|
|
|
|
|
I'll try that thanks.
|
|
|
|
|
Just set the click event for both buttons then do a select case on the sender object of the event like below:
<br />
private sub form_Click(ByVal send as System.Object, ByVal e as System.EventArgs)Handles form1Btn.Click, form2Btn.Click<br />
Select Case sender.name<br />
Case "form1"<br />
'do something here<br />
Case "form2"<br />
'do something else<br />
End Select<br />
End Sub<br />
That should do it. I did this for an airplane seating chart. Worked great. Each seat was really a button and once it was taken I put a big red X on it to show that is was not avaliable.
Tom
Tom Wright
tawright915@gmail.com
|
|
|
|