home *** CD-ROM | disk | FTP | other *** search
- // Lst44Obj.cpp : Implementation of Clst44App and DLL registration.
-
- #include "stdafx.h"
- #include "lst44.h"
- #include "Lst44Obj.h"
-
- /////////////////////////////////////////////////////////////////////////////
- //
-
- STDMETHODIMP CLst44Object::InterfaceSupportsErrorInfo(REFIID riid)
- {
- if (riid == IID_ILst44)
- return S_OK;
- return S_FALSE;
- }
-
-
- BSTR CreateBSTR(LPCSTR lpa)
- {
- BSTR bsz;
- UINT cch;
-
- cch = strlen(lpa);
-
- bsz = SysAllocStringLen(NULL, cch);
- if (bsz == NULL)
- return NULL;
-
- if (cch > 0)
- MultiByteToWideChar(CP_ACP, 0, lpa, cch, bsz, cch);
-
- bsz[cch] = NULL;
- return bsz;
- }
-
- STDMETHODIMP CLst44Object::GetMachineName(BSTR* retval)
- {
- ULONG ulLen;
-
- char *lpName;
-
- lpName = new char[MAX_PATH];
- ulLen = MAX_PATH;
-
- GetComputerName(lpName, &ulLen);
- *(lpName+ulLen) = '\0';
-
- if(ulLen == 0)
- *retval = NULL;
- else
- *retval = CreateBSTR(lpName);
-
- return S_OK;
-
- }