Real Software Forums
http://forums.realsoftware.com/

Using and calling a DLL from with Real Basic
http://forums.realsoftware.com/viewtopic.php?f=6&t=47725
Page 1 of 1

Author:  p0wn3d [ Sun Apr 28, 2013 2:23 am ]
Post subject:  Using and calling a DLL from with Real Basic

Hi,

Been through the LR but it's not too helpful on this subject. :(

I have created a simple windows dll in VB.NET named wmi.dll

Public Class wmi

Public Shared Function GetHDDSerialNumber(ByVal drive As String) As String
'check to see if the user provided a drive letter
'if not default it to "C"
If drive = "" OrElse drive Is Nothing Then
drive = "C"
End If
'create our ManagementObject, passing it the drive letter to the
'DevideID using WQL
Dim disk As New ManagementObject("Win32_LogicalDisk.DeviceID=""" + drive + ":""")
'bind our management object
disk.[Get]()
'return the serial number
Return disk("VolumeSerialNumber").ToString()
End Function
End Class


How would I go about calling and using this from RB

Thanks

:wink:

Author:  pixe656 [ Sun Apr 28, 2013 10:30 am ]
Post subject:  Re: Using and calling a DLL from with Real Basic

Something like this should work (bnot tested, I am not an expert at all...):
Declare Function GetH DDSerialNumberLib "wmi.dll" (Drive as string) as string
msgbox GetHDDSerialNumber("C")

I wouldn't know how to handle an optional parameter (the drive letter) in a call to a function in a dll, though.

Another issue that comes to my mind is that if you use a dll created using VB.NET, there is a possibility that it requires the corresponding framework to be installed on the machine running your application, which could be problematic. If that's the case, I would think it is better to use a direct windows API call. Have you checked the Windows Functionality Suite?

Pixe

Author:  Paul Lefebvre [ Sun Apr 28, 2013 6:11 pm ]
Post subject:  Re: Using and calling a DLL from with Real Basic

Real Studio cannot directly access managed .NET code.

Real Studio can only access standard Win32 DLLs, which you do using a simple declare to the function call in the DLL.

Author:  p0wn3d [ Mon Apr 29, 2013 11:32 am ]
Post subject:  Re: Using and calling a DLL from with Real Basic

Quote:
Real Studio cannot directly access managed .NET code.


Thanks Paul fully understand now. If i remember there was some examples in WFS

If anyone can post WFS 2.6 that would be great looks like ARBP are doing some website migration so download links are dead

:D

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/