Hi,
First, the fact that there are more examples for VB, does not say anything
about the language. It's just a matter of time before you can find a
GetComputerNameA example for LabVIEW (there are already examples, e.g.
http://www.air.nl/nlibrary/library.html).
Second, in LabVIEW you do not need to use API's to get the hostname. (See
attachment). A user could do most things without using external code. But if
you want to use external code, some effort has to be taken to get thing
working. Callbacks, clusters with string pointers and buffers are a bit
tricky (not impossible).
Third, LabVIEW can use header files. If they are in the correct format (e.g.
the format LV generates when you create a dll), LV automatically configures
the Call Library dialog. Perhaps someone likes to do this for all window
api's (perhaps I will do it...).
You can just call the Kernel32.dll directly. NI examples are often not to
good (in my opinion). They are often more difficult then the need to be.
Regards,
Wiebe.
"Joolz" wrote in message
news:506500000008000000BAA90000-1066448259000@exchange.ni.com...
> I'm a bit baffled by the Call Library function
>
> Say I want to use the windows API to (for example) get the machine
> name. In Visual Basic its easy (you just copy the code from one of the
> VB forums...!) and you get
>
> Private Declare Function api_GetComputerName Lib "kernel32" Alias
> "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
>
> Public Function GetMachine()
> Dim Buff As String
> Dim BuffSize As Long
> Dim result As Long
>
> BuffSize = 256
> Buff = Space$(BuffSize)
> result = api_GetComputerName(Buff, BuffSize)
> GetMachine = Trim$(Buff)
> Debug.Print Asc(Right(GetMachine, 1))
> If Right(GetMachine, 1) = Chr(0) Then GetMachine = Left(GetMachine,
> Len(GetMachine) - 1)
> End Function
>
> Now it seems that in LabView you use the Call Library Function to do
> this, but in the example "hostname.vi" with LV6.1, you have to make
> some other DLL, which I've no idea how to do. Can't you call the
> kernel32.dll directly? I thought the point of LabView was that
> halfwits like me don't have to learn C++
>
> Am I hopelessly confused?
>
> Or maybe some kind person has put all the Windows API functions in one
> set of VIs, so I don't have learn the difference between a handle and
> a pointer? Or even a tutorial that makes more sense than the LabView
> manual (not a terribly difficult task, as usual)
>
> Cheers
>
> Joolz
[Attachment GetComputerName.vi, see below]