Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Mon Jun 26, 2017 8:59 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Using and calling a DLL from with Real Basic
PostPosted: Sun Apr 28, 2013 2:23 am 
Offline
User avatar

Joined: Sun Oct 28, 2012 4:54 am
Posts: 264
Location: Herts, UK
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:

_________________
Real Studio 2012 R2
SysInfo
BackTrack Linux/BackBox Linux/Debian Lenny/Windows 7/Windows 8/OpenWRT/OpenBSD
& Yes it's me in the Avatar


Top
 Profile  
Reply with quote  
 Post subject: Re: Using and calling a DLL from with Real Basic
PostPosted: Sun Apr 28, 2013 10:30 am 
Offline

Joined: Wed May 20, 2009 11:02 am
Posts: 423
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

_________________
Using RS2011r4.3 on Windows7.


Top
 Profile  
Reply with quote  
 Post subject: Re: Using and calling a DLL from with Real Basic
PostPosted: Sun Apr 28, 2013 6:11 pm 
Offline
Site Admin
User avatar

Joined: Fri Sep 30, 2005 9:35 am
Posts: 987
Location: South Portland, Maine
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.

_________________
Paul Lefebvre
Developer Evangelist
Xojo, Inc.


Top
 Profile  
Reply with quote  
 Post subject: Re: Using and calling a DLL from with Real Basic
PostPosted: Mon Apr 29, 2013 11:32 am 
Offline
User avatar

Joined: Sun Oct 28, 2012 4:54 am
Posts: 264
Location: Herts, UK
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

_________________
Real Studio 2012 R2
SysInfo
BackTrack Linux/BackBox Linux/Debian Lenny/Windows 7/Windows 8/OpenWRT/OpenBSD
& Yes it's me in the Avatar


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group