 |
|
SQL Server Tips by Burleson |
XP_NET_ADDNAME
Before we describe this function we must first explain what is known
as a “NetBIOS Message Alias”. If you are familiar with sockets
programming then you can think of it as an end point e.g. Port 80 on
machine X. In NetBIOS, a simple string of up to 15 characters
identifies these end points. By default a number of these message
aliases will already be defined by Windows as it starts up. Normally
you will have the current user, the current machine and the current
domain or workgroup. You can see all the currently defined names by
issuing the following from a command prompt: “nbtstat –N”. To add a
name using the command line, you can use “NET NAME NameToAdd /ADD”.
Allowing you to add new names to the list will allow you to
customize the “From” parameter of XP_NET_SEND which is described
later. This XP takes a single string parameter, which is the name of
the message alias to add. The underlying SDK function used in this
XP is “NetMessageNameAdd”. Because this function only accepts
UNICODE strings, we use the XP_PT_UNICODETEXT and XP_UNICODETEXT
macros supplied by the XP++ framework to handle the Unicode string
manipulation. The following code snippet shows how we declare the 1
input string parameter for this XP and then obtain this parameter as
a UNICODE string prior to using it in the call to “NetMessageNameDel”:
BEGIN_IMPLEMENT_XP_PARAMETERS(CNetAddNameExtendedStoredProcedure)
XP_INPUT_PARAMETER(1, NULL, XP_ALLOW_BIGVARCHAR | XP_ALLOW_BIGCHAR |
XP_ALLOW_TEXT | XP_ALLOW_VARCHAR | XP_ALLOW_NTEXT |
XP_ALLOW_NVARCHAR, FALSE, FALSE, XP_PT_UNICODETEXT)
END_IMPLEMENT_XP_PARAMETERS(CNetAddNameExtendedStoredProcedure)
BOOL CNetAddNameExtendedStoredProcedure::Run()
{
//Validate our parameters
XP_ASSERT(m_pParameterData);
//Get the parameters
wchar_t* pszMessageName =
XP_UNICODETEXT(m_pParameterData[ADD_MESSAGE_NAME_INDEX].m_Data);
XP_ASSERT(pszMessageName);
.
.
.
The above book excerpt is from:
Super SQL
Server Systems
Turbocharge Database Performance with C++ External Procedures
ISBN:
0-9761573-2-2
Joseph Gama, P. J. Naughter
http://www.rampant-books.com/book_2005_2_sql_server_external_procedures.htm |