Similar Threads
1. C++ Question: Crashing C++
2. IMapiProp::CopyTo c++ question
What is proper way to use the lppProblems argument the IMapiProp::CopyTo
method? Lately, I have been sending in NULL but now would actually like to
get more verbose information on why the operation is failing.
thanks!
3. managed C++ question - .Net Framework
4. Visual C++ question
Hi All,
I am creating a class library project for VC++ in VS 2005. On
compilation, the following error is returned
error C2664: 'LookupAccountNameW' : cannot convert parameter 1 from
'char *' to 'LPCWSTR'
the line of concern is :
if ( ! LookupAccountName( argv[1], argv[2], userSid, &sidSize, refDom,
&domSize, &sidUse ) )
err( "LAN()", gle, false );
I think the problem lies in the fact that the .h file has a main
function which is as follows
int main( int argc, char *argv[] )
{
if ( argc != 3 )
{
puts( "Usage: lsa_lear <system name> <account name>" );
puts( "Enumerates privileges for the named account on the named
machine." );
puts( "<system name> is the machine where the lookup will
execute." );
puts( "<account name> is the account to examine, e.g. \"FOO\\felixk
\" or \"Administrators\"." );
return 1;
}
// open the policy object on the target computer
static SECURITY_QUALITY_OF_SERVICE sqos = { sizeof
SECURITY_QUALITY_OF_SERVICE, SecurityImpersonation,
SECURITY_DYNAMIC_TRACKING, FALSE };
static LSA_OBJECT_ATTRIBUTES lsaOA = { sizeof LSA_OBJECT_ATTRIBUTES,
NULL, NULL, 0, NULL, &sqos };
NTSTATUS nts;
LSA_HANDLE polHandle;
LsaUnicodeString systemName;
systemName = argv[1];
nts = LsaOpenPolicy( systemName, &lsaOA, GENERIC_READ |
GENERIC_EXECUTE, &polHandle );
err( "LOP()", nts );
// translate the account name to a RID plus associated domain SID
SID *userSid;
char refDom[MAX_PATH];
SID_NAME_USE sidUse;
DWORD sidSize, domSize;
const char *acctTypeString;
userSid = (SID *) malloc( MAX_PATH );
sidSize = domSize = MAX_PATH;
if ( ! LookupAccountName( argv[1], argv[2], userSid, &sidSize,
refDom, &domSize, &sidUse ) )
err( "LAN()", gle, false );
acctTypeString = NULL;
switch ( sidUse )
{
case SidTypeAlias:
case SidTypeUser:
case SidTypeGroup:
case SidTypeWellKnownGroup:
break;
case SidTypeDomain:
if ( acctTypeString == NULL )
acctTypeString = " domain";
// fall-through
case SidTypeInvalid:
if ( acctTypeString == NULL )
acctTypeString = "n invalid";
// fall-through
case SidTypeUnknown:
if ( acctTypeString == NULL )
acctTypeString = "n unknown";
// fall-through
case SidTypeDeletedAccount:
if ( acctTypeString == NULL )
acctTypeString = " deleted";
printf( "Don't know how to handle a%s account.\n",
acctTypeString );
return 1;
}
LsaUnicodeString *userRights;
ULONG count;
userRights = NULL;
count = 0;
nts = LsaEnumerateAccountRights( polHandle, userSid,
(LSA_UNICODE_STRING **) &userRights, &count );
err( "LEAR()", nts );
DWORD i;
char *p;
printf( "%d privileges for user \"%s\" in domain \"%s\":\n", count,
argv[2], refDom );
for ( i = 0; i < count; ++ i )
{
p = (char *) userRights[i]; // must free() later
printf( "priv %u: %s\n", i, p );
free( p );
}
LsaClose( polHandle );
free( userSid );
return 0;
}
Could someone assist me in getting rid of this problem.
Thanks
5. C++ question - CSharp/C#
6. Help - New to Managed C++ Question
Hi
I am an experienced C programmer and we have a large app written in C which
I have just recompiled with /clr to start to add in managed code to use .NET
framework and windows forms bit by bit.
I am new to managed C ++(and C++ for that matter).
I am struggling with the fact that it seems you cannot have global managed
variables although I think I understand why you can't.
i.e. if I declare a managed type or class or object as I would a normal C
global variable, I get a complier error:
error C3145 cannot declare a global or static managed type object or an _gc
pointer.
My big problem is I initially want to write some managed C++
functions/classes in a new C++ file which I then want to call from my
existing C code. However these new managed C++ functions need to preserve
data between themselves and between calls from the C code so it seemed
global variables where the ideal solution.
So the scenario is something like
C code
call managed C++ function 1 to initialize data
loop
do some processing
call managed C++ function 2 to work with initialized data
end loop
C++ code
function1
creates some managed data (but where does it preserve this if I cant have
global managed variables)
funtion2
works on previously created managed data
Can anyone advise on how best to tackle this problem.
Thanks
Steve
7. Managed C++ - Question
8. unmanaged & managed C++ questions
1. I want to be use mix unmanaged code with managed code. In particular,
the unmanaged code uses MFC CFile to perform file I/O. Can CFile be used
in unmanaged code that is mixes with managed code? I've tried this but
keep getting a system::exception is thrown with the message "External
component has thrown an exception" when the CFile instance is created.
2. How does the assignment operator check to see that the source and
destination objects are not the same in managed code? For example:
ref class A
{
A% operator=( A %a )
{
// if( this != &a ) // this line generates a compiler error.
{
...
}
}
};
The compile generates the error message "error C2446: '!=' : no conversion
from 'const CManaged' to 'CManaged ^const '" when the line "if( this !=
&a )" is uncommented. While this is to be expected, what is the proper way
to check if the source and destination objects are the same?
Ian