MichaelRed: Right so.
Came from copying and pasting.
However, I trust that anyone using any code posted in this forum(usually snippits or just ideas, and sometimes the ways that someone is actually using the code that they have posted is somewhat different) would have enough understanding to correct the minor typos, etc.
If not, then they need to ask.
If still not, then maybe they are the ones who are "at least one cup (of coffee) short".
Often, perfect or 100% correct code isn't posted, and also often missing error handling, or other points.
I am sure it also isn't expected.
(New) ideas, different methods and sample code is what makes this forum attractive, and not necessarily 100% syntax correct code.
Otherwise, if this isn't understood, then maybe code like this shouldn't be used at all until some basics are better understood.
I would, however, expect that code posted in a FAQ, on the other hand, would be more correct and somewhat more professional.
>The API declaration and procedure name cannot be the same.
It can be easily seen that the proceedure name should have been: Sp_GetComputerName
Anyone in doubt could ask, or, someone spotting these minor erros, could post a line of correction if they have doubt that some beginner may not know how to correct the error.
>(also need to 'loose' the "sp_"...
Wouldn't help, as then the problem being that two functions (the API function and Proceedure name) cannot be the same.
Thanks for pointing it out.
Again, the below code is just an idea of how the objective can be accomplished, and not necessarily an end product with 100% correctness:
Option Explicit
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Public Function GetComputerName_pF() As String
Dim lpBuffer As String
Dim pos
lpBuffer = Space$(255)
GetComputerName lpBuffer, Len(lpBuffer)
pos = InStr(lpBuffer, Chr$(0))
If pos > 0 Then GetComputerName_pF = Left$(lpBuffer, pos - 1)
End Function [/b][/i][/u]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!