|
why can't i edit the string "#include<iostream>" and "#include<string> "on this page?
|
|
|
|
|
I got the answer
the statment should be cout << myGradeBook.getCourseName();
Then the result will be on the screen!
WOW!
|
|
|
|
|
You could also have used your displayMessage() function, which does the same thing for you. Remember the definition of your getCourseName() function, is just to return the string containing the name, so you still need to pass that to a function that will display it, or, as in this case, pass it directly to cout .
|
|
|
|
|
|
Hello people I have the following the code written in C++, converted from Vb.net to C++ from a program, the following code tells the user via message box if the program is running as an admin, see below
Object ^identity = WindowsIdentity::GetCurrent();
WindowsPrincipal ^principal = gcnew WindowsPrincipal(identity);
bool isElevated = principal->IsInRole(WindowsBuiltInRole::Administrator);
try
{
if (isElevated == true)
{
}
else
{
MessageBox::Show("WARNING: Program not running as administrator!", "Credential Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
}
}
catch (Exception ^ex)
{
MessageBox::Show("This program cannot run as performed because your system does not support admin rights, program now terminating from computer memory.", ".Net Framework Error", MessageBoxButtons::OK, MessageBoxIcon::Error);
Environment::Exit(1);
}
When this block of code was executed with my program, I get the following error message (In double quotations):
"error C2664: 'System::Security::Principal::WindowsPrincipal::WindowsPrincipal(System::Security::Principal::WindowsIdentity ^)' : cannot convert parameter 1 from 'System::Object ^' to 'System::Security::Principal::WindowsIdentity ^'"
the remaining error messages are (In double quotations):
"1> No user-defined-conversion operator available, or
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast"
Could anyone point out something that I could edit that could make the compiler accept or work, any suggestions or personal solutions are appreciated .
|
|
|
|
|
Brandon-hbx12000 wrote: Object ^identity = WindowsIdentity::GetCurrent();
The problem is in the very first word. Why would you "anonimize" whatever it is GetCurrent() returns? Use real types where ever you can.
|
|
|
|
|
thank you 
|
|
|
|
|
You're welcome.
|
|
|
|
|
You have stored the return from your call to WindowsIdentity::GetCurrent() as an object reference. You are then sending that object reference to the WindowsPrincipal() constructor, which expects a WindowsIdentity reference as documented here[^]. The compiler is complaining because it does not feel able to promote an object reference to a higher level. Save your WindowsIdentity object as a WindowsIdentity reference.
|
|
|
|
|
thank you 
|
|
|
|
|
|
Hi all,
Hoping you can help me out. I've been trying to track down a handle leak in our product for the last few days, and I've gotten to the point where I suspect something is happening outside of our code. It seems that everytime my application calls _beginthread, there is 5 handles that leak. This happens to be our Server application, which receives many requests and calls to _beginthread, so after a period of time, this gets ugly.
This application is compiled with /clr to use code written in a .DLL for LDAP Authentication. But regardless of whether nor not any C#/DLL code gets ran, we're still leaking. I commented EVERYTHING out, except a call to _beginthread. Inside the thread proc, all I do is call _endthread... And the problem still occurs - 5 handles on every call.. This is verified using Process Explorer and the WinDbg tool.
If I turn off the /clr flag, and the problem goes away...
I did a !htrace in WinDbg, and this is what its showing me..
Outstanding handles opened since the previous snapshot:
--------------------------------------
Handle = 0x00000240 - OPEN
Thread ID = 0x00003754, Process ID = 0x000038a4
0x77cb4210: ntdll!ZwCreateEvent+0x0000000c
0x7796b857: KERNEL32!CreateEventExW+0x0000006e
0x7796b8a6: KERNEL32!CreateEventW+0x00000027
0x72b86fdf: mscorwks!CLREvent::CreateManualEvent+0x00000027
0x72b21575: mscorwks!Thread::AllocHandles+0x0000009b
0x72b235e2: mscorwks!Thread::InitThread+0x000001a4
0x72b21f21: mscorwks!SetupThread+0x000002b2
0x72bf9aac: mscorwks!IJWNOADThunk::FindThunkTarget+0x00000019
0x72bf9f39: mscorwks!IJWNOADThunkJumpTargetHelper+0x0000000b
0x72a21ae1: mscorwks!IJWNOADThunkJumpTarget+0x00000048
0x0f59dbd3: MSVCR90D!_beginthread+0x00000233
0x0f59db6e: MSVCR90D!_beginthread+0x000001ce
0x7796d309: KERNEL32!BaseThreadInitThunk+0x0000000e
--------------------------------------
Handle = 0x0000023c - OPEN
Thread ID = 0x00003754, Process ID = 0x000038a4
0x77cb4210: ntdll!ZwCreateEvent+0x0000000c
0x7796b857: KERNEL32!CreateEventExW+0x0000006e
0x7796b8a6: KERNEL32!CreateEventW+0x00000027
0x72b86fdf: mscorwks!CLREvent::CreateManualEvent+0x00000027
0x72b21569: mscorwks!Thread::AllocHandles+0x0000008f
0x72b235e2: mscorwks!Thread::InitThread+0x000001a4
0x72b21f21: mscorwks!SetupThread+0x000002b2
0x72bf9aac: mscorwks!IJWNOADThunk::FindThunkTarget+0x00000019
0x72bf9f39: mscorwks!IJWNOADThunkJumpTargetHelper+0x0000000b
0x72a21ae1: mscorwks!IJWNOADThunkJumpTarget+0x00000048
0x0f59dbd3: MSVCR90D!_beginthread+0x00000233
0x0f59db6e: MSVCR90D!_beginthread+0x000001ce
0x7796d309: KERNEL32!BaseThreadInitThunk+0x0000000e
--------------------------------------
Handle = 0x00000238 - OPEN
Thread ID = 0x00003754, Process ID = 0x000038a4
0x77cb4210: ntdll!ZwCreateEvent+0x0000000c
0x7796b857: KERNEL32!CreateEventExW+0x0000006e
0x7796b8a6: KERNEL32!CreateEventW+0x00000027
0x72b86fdf: mscorwks!CLREvent::CreateManualEvent+0x00000027
0x72b2155d: mscorwks!Thread::AllocHandles+0x00000083
0x72b235e2: mscorwks!Thread::InitThread+0x000001a4
0x72b21f21: mscorwks!SetupThread+0x000002b2
0x72bf9aac: mscorwks!IJWNOADThunk::FindThunkTarget+0x00000019
0x72bf9f39: mscorwks!IJWNOADThunkJumpTargetHelper+0x0000000b
0x72a21ae1: mscorwks!IJWNOADThunkJumpTarget+0x00000048
0x0f59dbd3: MSVCR90D!_beginthread+0x00000233
0x0f59db6e: MSVCR90D!_beginthread+0x000001ce
0x7796d309: KERNEL32!BaseThreadInitThunk+0x0000000e
--------------------------------------
Handle = 0x00000234 - OPEN
Thread ID = 0x00003754, Process ID = 0x000038a4
0x77cb4210: ntdll!ZwCreateEvent+0x0000000c
0x7796b857: KERNEL32!CreateEventExW+0x0000006e
0x7796b8a6: KERNEL32!CreateEventW+0x00000027
0x72b86fdf: mscorwks!CLREvent::CreateManualEvent+0x00000027
0x72b21551: mscorwks!Thread::AllocHandles+0x00000077
0x72b235e2: mscorwks!Thread::InitThread+0x000001a4
0x72b21f21: mscorwks!SetupThread+0x000002b2
0x72bf9aac: mscorwks!IJWNOADThunk::FindThunkTarget+0x00000019
0x72bf9f39: mscorwks!IJWNOADThunkJumpTargetHelper+0x0000000b
0x72a21ae1: mscorwks!IJWNOADThunkJumpTarget+0x00000048
0x0f59dbd3: MSVCR90D!_beginthread+0x00000233
0x0f59db6e: MSVCR90D!_beginthread+0x000001ce
0x7796d309: KERNEL32!BaseThreadInitThunk+0x0000000e
--------------------------------------
Handle = 0x0000022c - OPEN
Thread ID = 0x00003754, Process ID = 0x000038a4
0x77cb4680: ntdll!ZwDuplicateObject+0x0000000c
0x77963d92: KERNEL32!DuplicateHandle+0x0000012b
0x72b2365f: mscorwks!Thread::InitThread+0x00000174
0x72b21f21: mscorwks!SetupThread+0x000002b2
0x72bf9aac: mscorwks!IJWNOADThunk::FindThunkTarget+0x00000019
0x72bf9f39: mscorwks!IJWNOADThunkJumpTargetHelper+0x0000000b
0x72a21ae1: mscorwks!IJWNOADThunkJumpTarget+0x00000048
0x0f59dbd3: MSVCR90D!_beginthread+0x00000233
0x0f59db6e: MSVCR90D!_beginthread+0x000001ce
0x7796d309: KERNEL32!BaseThreadInitThunk+0x0000000e
0x77c916c3: ntdll!__RtlUserThreadStart+0x00000023
0x77c91696: ntdll!_RtlUserThreadStart+0x0000001b
--------------------------------------
I've exhausted everything I can - have you seen this before? What do you recommend in further debugging the problem? I'm using VS.2008. I don't believe you can specify in the C++ Project the .NET version (thought perhaps it was fixed in a later version) ..
Any help and or suggestions you may have would be greatly appreciated, thanks.
Mike
|
|
|
|
|
hi,
I have an aplication whose view is based in TabControl. It has three tab and one of them have a Edit control. I'd like show text in this edit control when I press a button. I thought do a global variable that keep a valor, for example 1, and in the method, to do a control that show text only if the variable have valor 1.
But my problem is after press button, don't happen something. I think that I must to update the view with the method onUpdate or something like that.. but I dont know how.
What do you think?
This is my aplication:
http://i54.tinypic.com/1e9qtx.png
This is code :
http://www.megaupload.com/?d=1QT43LOQ[^]
|
|
|
|
|
|
In C++ on VS 2005 , createfile API fails with Invalid file handle error in below scenrio.
1.Consider user A and user B are both part of administrator group and i logged in to machine as user A and started one service application with user B. This program creates files on mapped network drive.
so i started this program with user B then below createfile API fails with invalid handle error when i try to create a file on mapped network drive ,though user A and B both part of administrator group on windows.
This happens on windows server 2003 and 2008 also.
In Win 2008 i turned off UAC but same behaviour.
Any other setting need to be done while creating mapped network drive ?
Usre who is creating a mapped network drive is the only one who can write file to it ?
While creating a network drive i logged in as user A, but file is created on this drive by user B , but since both are part of administrator why user B is NOT allowed to create a file on mapped network drive ?
Thanks.
//code i tried
DWORD dwAccess = CREATE_NEW;
HANDLE hFile = CreateFile(sTempFile, GENERIC_WRITE,
0, NULL, dwAccess, FILE_ATTRIBUTE_NORMAL, NULL);
DWORD errCode = GetLastError();
|
|
|
|
|
I have following header file and library. using this header file and library i want create DLL in VC++. then this DLL I can use in vb.net. I added this header file and library file in my vc++ project but at the time of create build it gating error.
i think I need _declspec(dllexport) int capture_data(unsigned char ** raw_image, unsigned char **
fmr_data, int templateLen[]) this function Please suggest me how can i Add this function.
1. MORPHO_Types.h
2. MORPHO_TemplateList.h
3. MORPHO_FieldList.h
4. MORPHO_User.h
5. MORPHO_UserList.h
6. MORPHO_FieldDescriptor.h
7. MORPHO_Database.h
8. MORPHO_Device.h
9. MORPHO_Errors.h
10. MORPHO_Image.h
11. MORPHO_Interface.h
1 MORPHO_SDK.lib (functions that communicate with device)
2.MORPHO_SDK_Image.lib (functions that display images from device)
my mail id is ravi.ranadive@gmail.com
|
|
|
|
|
Just asking an interview question.
In Windows perspective what is the difference between a user dump and kernel dump?
|
|
|
|
|
Consider: what is the difference between user space and kernel space?
Also consider whether this really has anything at all to do with Managed C++/CLI.
|
|
|
|
|
Pls, check my codes. I added app.config file into project. codes are
<configuration>
<connectionStrings>
<add name ="SQLConnection" providerName="Oracle.DataAccess.Client"
connectionString="Data Source=localhost:1521/orcl; user id=scott; password=tiger"/>
</connectionStrings>
</configuration>
In C++/CLI file I tried to connect Oracle DB but failed. Codes are like below
#include "stdafx.h"
using namespace System;
using namespace System::Data;
using namespace System::Data::Common;
using namespace System::Configuration;
using namespace Oracle::DataAccess::Client;
int main(array ^args)
{
try{
String^ provider = ConfigurationManager::ConnectionStrings["SQLConnection"]->ProviderName;
DbProviderFactory^ factory = DbProviderFactories::GetFactory(provider);
DbConnection^ conn = factory->CreateConnection();
String^ connection = ConfigurationManager::ConnectionStrings["SQLConnection"]->ConnectionString;
conn->ConnectionString = connection;
conn->Open(); //Exception Occurs!
}
catch (Exception^ e) {
Console::WriteLine(e->Message);
}
return 0;
}
Exception is ora-12541 No Listener. But "tnsping orcl" is done well. and I executed "lsnrctl start".
I need your advice. Thanks in advance.
Best Regards.
Joseph Hwang
|
|
|
|
|
hello.
how do i realize the interaction between managed and unmanaged code inside a mixed assembly dll? assume the dll exposes an unmanaged API and shall be callable from unmanaged client code.
I understand that by using delegates I can rout unmanaged functions to managed functions, however I need to create managed objects first.
how can the creation or initialization of managed objects be achieved if user entrypoints may only contain unmanaged code and automated entry-points should be deactivated due to the dll load bug?
thanx for any advice
modified on Friday, September 9, 2011 6:13 AM
|
|
|
|
|
It's not clear what you're asking. Can you restate the question in one sentence?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hi,
I want to connect through proxy server, so i need to hook the send function and want to change the sending buffer (data) with my few addition .How can i do that.. i am using detours for hooking
|
|
|
|
|
Hello all,
I have a problem I just can't solve.
I have a c++ dll that returns a VARIANT of type VT_ARRAY|VT_BYREF|VT_BSTR.
following what was explained in Step by Step: Calling C++ DLLs from VC++ and VB - Part 3[^]. I turned my whole C++ process into a class.
On the vb side, I have a string array that receives the info back from the C++ dll
it is declared at a form level as private myarray() as string
The problem is that the first time I use it, it works perfectly. But if I push the button a second time, the whole process works until the dll reaches the point where it returns the variant and it just fails.
I don't understand. I'm pretty sure the class is destroyed the first time and so any value contained in the variant is deleted.
Also in vb if I unload and reload the dll every time, then it works well. So it's not an array problem on vb part (and I tried redim and erase and all). But I don't really want to load and unload every time, seems like bad programming and it creates other problems anyway.
So to summarise:
From vb6:
1-call C++ dll to create class
2-call class function to return array
3-call C++ dll to destroy class
first time works without a glinch, second time gets an error when returning the array.
Please help, it's driving me crazy.
Oh and as you might have guessed I'm a noob with C++
Many thanks
|
|
|
|
|
It might help if you reveal the exact error that causes the process to fail.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hi, thank you for helping.
If I'm in vb it just crashes so not helpful and in vc the debugger gives me:
Unhandled exception in project.exe (OLEAUT32.DLL): 0xC0000005: Access Violation.
Then it stops at:
77154281 push dword ptr [eax]
So I didn't think it would be that helpful. But as I said, I'm going crazy so thanks again for helping.
|
|
|
|