admin
base
com
developer
drivers
ds
adsi
dbgexts
deldsm
docs
drt
errmsg
include
ldap
ldapc
msext
nds
ndsext
nocairo
noole
novellnw
nw312
nwnds
nwutils
oledsiid
oledsvw
public
router
setup
tlb
types
utils
winnt
common
support
win95
winnt
_windows_nt_provider_component_description.htm
adsi_winnt_provider_{f273c0c6-f889-47a9-abcb-c03e0a193bbb}.sld
ccache.cxx
ccache.hxx
ccgi.cxx
ccgi.hxx
ccomp.cxx
ccomp.hxx
ccred.cxx
ccred.hxx
cdispmgr.cxx
cdispmgr.hxx
cdomain.cxx
cdomain.hxx
cdompwd.cxx
cdompwd.hxx
cenmfpre.cxx
cenmfpre.hxx
cenmfpse.cxx
cenmfpse.hxx
cenmfpsh.cxx
cenmfpsh.hxx
cenmlgrp.cxx
cenmlgrp.hxx
cenumcom.cxx
cenumcom.hxx
cenumdom.cxx
cenumdom.hxx
cenumfsh.cxx
cenumfsh.hxx
cenumgrp.cxx
cenumgrp.hxx
cenumjob.cxx
cenumjob.hxx
cenumns.cxx
cenumns.hxx
cenumres.cxx
cenumres.hxx
cenumsch.cxx
cenumsch.hxx
cenumses.cxx
cenumses.hxx
cenumusr.cxx
cenumusr.hxx
cenumvar.cxx
cenumvar.hxx
cextmgr.cxx
cextmgr.hxx
cfpnwfsh.cxx
cfpnwfsh.hxx
cfpnwres.cxx
cfpnwres.hxx
cfpnwses.cxx
cfpnwses.hxx
cfpnwsrv.cxx
cfpnwsrv.hxx
cfserv.cxx
cfserv.hxx
cfshare.cxx
cfshare.hxx
cggi.cxx
cggi.hxx
cgroup.cxx
cgroup.hxx
cgroups.cxx
cgroups.hxx
cjob.cxx
cjob.hxx
clgroups.cxx
clgroups.hxx
cnamcf.cxx
cnamcf.hxx
cnamesp.cxx
cnamesp.hxx
cobjcach.cxx
cobjcach.hxx
common.cxx
common.hxx
core.cxx
core.hxx
cpgi.cxx
cpgi.hxx
cprinter.cxx
cprinter.hxx
cprops.cxx
cprops.hxx
cprov.cxx
cprov.hxx
cprovcf.cxx
cprovcf.hxx
credel.cxx
credel.hxx
cres.cxx
cres.hxx
cschema.cxx
cschema.hxx
cserv.cxx
cserv.hxx
csess.cxx
csess.hxx
cuar.cxx
cuar.hxx
cuas.cxx
cuas.hxx
cubi.cxx
cubi.hxx
cumiconn.cxx
cumiconn.hxx
cumicurs.cxx
cumicurs.hxx
cumiobj.cxx
cumiobj.hxx
cumiprop.cxx
cumiprop.hxx
cuoi.cxx
cuoi.hxx
cuser.cxx
cuser.hxx
cusers.cxx
cusers.hxx
dirs
extension.cxx
extension.hxx
fpnwutil.cxx
fpnwutil.hxx
fsmacro.h
getobj.cxx
getobj.hxx
globals.cxx
globals.hxx
grput2.cxx
grput2.hxx
grput3.cxx
grput3.hxx
grputils.cxx
grputils.hxx
guid.c
guid.h
ids.hxx
jobhlp.cxx
jobhlp.hxx
libmain.cxx
macro.h
makefil0
nt2ods.cxx
nt2ods.hxx
nt2umi.cxx
nt2umi.hxx
nt2var.cxx
nt2var.hxx
ntcopy.cxx
ntcopy.hxx
ntmrshl.cxx
ntmrshl.hxx
nttypes.h
ntumrshl.cxx
ntumrshl.hxx
object.cxx
object.hxx
ods2nt.cxx
ods2nt.hxx
parse.cxx
parse.hxx
printhlp.cxx
printhlp.hxx
property.cxx
property.hxx
servhlp.cxx
servhlp.hxx
structs.hxx
system.cxx
system.hxx
umi.cxx
umi.hxx
umi2nt.cxx
umi2nt.hxx
umi_i.c
umiconcf.cxx
umiconcf.hxx
umierr.hxx
umiglob.cxx
umiglob.hxx
var2nt.cxx
var2nt.hxx
winnt.def
winnt.hxx
winnt.odl
winnt.rc
winnt2.h
winntrc.h
xml
adoinst.cmd
adsi40.mk
dirs
distnt40.cmd
install.cmd
makedist.cmd
makefil0
makerel.cmd
oleds.inc
relnt40.cmd
sources.inc
dns
ds
edb500
ese98
inc
nameres
netapi
nlrepl
nw
published
safealloca
security
win32
xpress
dirs
project.mk
enduser
inetcore
inetsrv
loc
mergedcomponents
multimedia
net
printscan
public
published
sdktools
shell
termsrv
tools
windows
dirs
makefil0
418 lines
8.0 KiB
C++
418 lines
8.0 KiB
C++
//+---------------------------------------------------------------------------
|
|
//
|
|
// Microsoft Windows
|
|
// Copyright (C) Microsoft Corporation, 1992 - 1995.
|
|
//
|
|
// File: winnt2var.cxx
|
|
//
|
|
// Contents: WinNT Object to Variant Copy Routines
|
|
//
|
|
// Functions:
|
|
//
|
|
// History: 06/12/96 RamV Created.
|
|
// cloned off NDS conversion code.
|
|
//
|
|
// Issues: Check null ptrs for AllocADsMem and AllocADsStr
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
// NTType objects copy code
|
|
//
|
|
|
|
#include "winnt.hxx"
|
|
#pragma hdrstop
|
|
#define INITGUID
|
|
|
|
void
|
|
VarTypeFreeVarObjects(
|
|
PVARIANT pVarObject,
|
|
DWORD dwNumValues
|
|
)
|
|
{
|
|
DWORD i = 0;
|
|
|
|
if( !pVarObject){
|
|
return;
|
|
}
|
|
|
|
for (i = 0; i < dwNumValues; i++ ) {
|
|
VariantClear(pVarObject + i);
|
|
}
|
|
|
|
FreeADsMem(pVarObject);
|
|
|
|
return;
|
|
}
|
|
|
|
HRESULT
|
|
NTTypeToVarTypeCopyOctetString(
|
|
PNTOBJECT pNTSrcValue,
|
|
PVARIANT lpVarDestObject
|
|
)
|
|
{
|
|
HRESULT hr = S_OK;
|
|
|
|
if(!lpVarDestObject){
|
|
RRETURN(E_POINTER);
|
|
}
|
|
|
|
hr = BinaryToVariant(
|
|
(pNTSrcValue->NTValue).octetstring.dwSize,
|
|
(pNTSrcValue->NTValue).octetstring.pByte,
|
|
lpVarDestObject
|
|
);
|
|
|
|
RRETURN(hr);
|
|
}
|
|
|
|
HRESULT
|
|
NTTypeToVarTypeCopyBOOL(
|
|
PNTOBJECT pNTSrcValue,
|
|
PVARIANT lpVarDestObject
|
|
)
|
|
{
|
|
HRESULT hr = S_OK;
|
|
|
|
if(!lpVarDestObject){
|
|
RRETURN(E_POINTER);
|
|
}
|
|
|
|
if(!pNTSrcValue){
|
|
RRETURN(E_POINTER);
|
|
}
|
|
|
|
lpVarDestObject->vt = VT_BOOL;
|
|
|
|
if((pNTSrcValue->NTValue).fValue){
|
|
lpVarDestObject->boolVal = VARIANT_TRUE; // notation for TRUE in V_BOOL
|
|
} else {
|
|
lpVarDestObject->boolVal = VARIANT_FALSE;
|
|
}
|
|
|
|
RRETURN(hr);
|
|
}
|
|
|
|
HRESULT
|
|
NTTypeToVarTypeCopySYSTEMTIME(
|
|
PNTOBJECT pNTSrcValue,
|
|
PVARIANT lpVarDestObject
|
|
)
|
|
{
|
|
HRESULT hr;
|
|
|
|
if(!pNTSrcValue){
|
|
RRETURN(E_POINTER);
|
|
}
|
|
|
|
if(!lpVarDestObject){
|
|
RRETURN(E_POINTER);
|
|
}
|
|
|
|
lpVarDestObject->vt = VT_DATE;
|
|
|
|
hr = ConvertSystemTimeToDATE (pNTSrcValue->NTValue.stSystemTimeValue,
|
|
&lpVarDestObject->date );
|
|
|
|
|
|
RRETURN(hr);
|
|
}
|
|
|
|
HRESULT
|
|
NTTypeToVarTypeCopyDWORD(
|
|
PNTOBJECT pNTSrcValue,
|
|
PVARIANT lpVarDestObject
|
|
)
|
|
{
|
|
//
|
|
// we cast the DWORD to a LONG
|
|
//
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
if(!lpVarDestObject){
|
|
RRETURN(E_POINTER);
|
|
}
|
|
|
|
if(!pNTSrcValue){
|
|
RRETURN(E_POINTER);
|
|
}
|
|
|
|
lpVarDestObject->vt = VT_I4;
|
|
|
|
lpVarDestObject->lVal = (LONG)(pNTSrcValue->NTValue).dwValue;
|
|
|
|
RRETURN(hr);
|
|
}
|
|
|
|
HRESULT
|
|
NTTypeToVarTypeCopyDATE70(
|
|
PNTOBJECT pNTSrcValue,
|
|
PVARIANT lpVarDestObject
|
|
)
|
|
{
|
|
//
|
|
// we cast the DWORD to a LONG
|
|
//
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
if(!lpVarDestObject){
|
|
RRETURN(E_POINTER);
|
|
}
|
|
|
|
if(!pNTSrcValue){
|
|
RRETURN(E_POINTER);
|
|
}
|
|
|
|
lpVarDestObject->vt = VT_DATE;
|
|
|
|
hr = ConvertDWORDtoDATE(
|
|
(pNTSrcValue->NTValue).dwSeconds1970,
|
|
&(lpVarDestObject->date)
|
|
);
|
|
|
|
RRETURN(hr);
|
|
}
|
|
|
|
|
|
HRESULT
|
|
NTTypeToVarTypeCopyDATE(
|
|
PNTOBJECT pNTSrcValue,
|
|
PVARIANT lpVarDestObject
|
|
)
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
|
SYSTEMTIME stSystemTime;
|
|
SYSTEMTIME LocalTime;
|
|
DATE date;
|
|
BOOL fRetval;
|
|
|
|
GetSystemTime( &stSystemTime);
|
|
|
|
fRetval = SystemTimeToTzSpecificLocalTime(
|
|
NULL,
|
|
&stSystemTime,
|
|
&LocalTime
|
|
);
|
|
if(!fRetval){
|
|
RRETURN(HRESULT_FROM_WIN32(GetLastError()));
|
|
}
|
|
|
|
stSystemTime.wHour = (WORD)(pNTSrcValue->NTValue.dwValue)/60;
|
|
stSystemTime.wMinute = (WORD)(pNTSrcValue->NTValue.dwValue)%60;
|
|
stSystemTime.wSecond =0;
|
|
stSystemTime.wMilliseconds = 0;
|
|
|
|
if(!lpVarDestObject){
|
|
RRETURN(E_POINTER);
|
|
}
|
|
|
|
if(!pNTSrcValue){
|
|
RRETURN(E_POINTER);
|
|
}
|
|
|
|
lpVarDestObject->vt = VT_DATE;
|
|
|
|
hr = ConvertSystemTimeToDATE (stSystemTime,
|
|
&date );
|
|
BAIL_ON_FAILURE(hr);
|
|
|
|
// We are casting date to DWORD and then subtracting it from date, which is double,
|
|
// so that we only keep hours and minutes related info from the source DATE
|
|
lpVarDestObject->date = date - (DWORD)date;
|
|
|
|
|
|
error:
|
|
|
|
RRETURN(hr);
|
|
}
|
|
|
|
HRESULT
|
|
NTTypeToVarTypeCopyLPTSTR(
|
|
PNTOBJECT pNTSrcValue,
|
|
PVARIANT lpVarDestObject
|
|
)
|
|
{
|
|
HRESULT hr = S_OK;
|
|
|
|
if(!lpVarDestObject){
|
|
RRETURN(E_POINTER);
|
|
}
|
|
|
|
lpVarDestObject->vt = VT_BSTR;
|
|
|
|
if(!(pNTSrcValue->NTValue).pszValue){
|
|
lpVarDestObject->bstrVal = NULL;
|
|
hr = S_OK;
|
|
goto error;
|
|
}
|
|
|
|
|
|
if(!pNTSrcValue){
|
|
lpVarDestObject->bstrVal = NULL;
|
|
} else {
|
|
hr = ADsAllocString((pNTSrcValue->NTValue).pszValue,
|
|
&(lpVarDestObject->bstrVal));
|
|
}
|
|
|
|
error:
|
|
RRETURN(hr);
|
|
}
|
|
|
|
|
|
HRESULT
|
|
NtTypeToVarTypeCopy(
|
|
PNTOBJECT lpNtSrcObject,
|
|
PVARIANT lpVarDestObject
|
|
)
|
|
{
|
|
HRESULT hr = S_OK;
|
|
switch (lpNtSrcObject->NTType) {
|
|
case NT_SYNTAX_ID_BOOL:
|
|
hr = NTTypeToVarTypeCopyBOOL(
|
|
lpNtSrcObject,
|
|
lpVarDestObject
|
|
);
|
|
break;
|
|
|
|
case NT_SYNTAX_ID_SYSTEMTIME:
|
|
hr = NTTypeToVarTypeCopySYSTEMTIME(
|
|
lpNtSrcObject,
|
|
lpVarDestObject
|
|
);
|
|
break;
|
|
|
|
|
|
case NT_SYNTAX_ID_DWORD:
|
|
hr = NTTypeToVarTypeCopyDWORD(
|
|
lpNtSrcObject,
|
|
lpVarDestObject
|
|
);
|
|
break;
|
|
|
|
case NT_SYNTAX_ID_DATE:
|
|
hr = NTTypeToVarTypeCopyDATE(
|
|
lpNtSrcObject,
|
|
lpVarDestObject
|
|
);
|
|
break;
|
|
|
|
case NT_SYNTAX_ID_LPTSTR:
|
|
hr = NTTypeToVarTypeCopyLPTSTR(
|
|
lpNtSrcObject,
|
|
lpVarDestObject
|
|
);
|
|
break;
|
|
|
|
case NT_SYNTAX_ID_DelimitedString:
|
|
|
|
hr = NTTypeToVarTypeCopyLPTSTR(
|
|
lpNtSrcObject,
|
|
lpVarDestObject
|
|
);
|
|
break;
|
|
|
|
case NT_SYNTAX_ID_NulledString :
|
|
hr = NTTypeToVarTypeCopyLPTSTR(
|
|
lpNtSrcObject,
|
|
lpVarDestObject
|
|
);
|
|
|
|
break;
|
|
|
|
|
|
case NT_SYNTAX_ID_DATE_1970:
|
|
hr = NTTypeToVarTypeCopyDATE70(
|
|
lpNtSrcObject,
|
|
lpVarDestObject
|
|
);
|
|
break;
|
|
case NT_SYNTAX_ID_OCTETSTRING :
|
|
hr = NTTypeToVarTypeCopyOctetString(
|
|
lpNtSrcObject,
|
|
lpVarDestObject
|
|
);
|
|
break;
|
|
|
|
default:
|
|
hr = E_FAIL;
|
|
break;
|
|
}
|
|
|
|
RRETURN(hr);
|
|
}
|
|
|
|
|
|
|
|
HRESULT
|
|
NtTypeToVarTypeCopyConstruct(
|
|
LPNTOBJECT pNtSrcObjects,
|
|
DWORD dwNumObjects,
|
|
PVARIANT pVarDestObjects
|
|
)
|
|
{
|
|
|
|
long i = 0;
|
|
HRESULT hr = S_OK;
|
|
|
|
VariantInit( pVarDestObjects );
|
|
|
|
//
|
|
// The following are for handling are multi-value properties
|
|
//
|
|
|
|
SAFEARRAY *aList = NULL;
|
|
SAFEARRAYBOUND aBound;
|
|
|
|
aBound.lLbound = 0;
|
|
aBound.cElements = dwNumObjects;
|
|
|
|
aList = SafeArrayCreate( VT_VARIANT, 1, &aBound );
|
|
|
|
if ( aList == NULL )
|
|
{
|
|
hr = E_OUTOFMEMORY;
|
|
BAIL_ON_FAILURE(hr);
|
|
}
|
|
|
|
for ( i = 0; i < (long) dwNumObjects; i++ )
|
|
{
|
|
VARIANT v;
|
|
|
|
VariantInit(&v);
|
|
hr = NtTypeToVarTypeCopy( pNtSrcObjects + i,
|
|
&v );
|
|
BAIL_ON_FAILURE(hr);
|
|
|
|
hr = SafeArrayPutElement( aList, &i, &v );
|
|
VariantClear(&v);
|
|
BAIL_ON_FAILURE(hr);
|
|
}
|
|
|
|
V_VT(pVarDestObjects) = VT_ARRAY | VT_VARIANT;
|
|
V_ARRAY(pVarDestObjects) = aList;
|
|
|
|
RRETURN(S_OK);
|
|
|
|
error:
|
|
|
|
if ( aList )
|
|
SafeArrayDestroy( aList );
|
|
|
|
RRETURN(hr);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|