|
i even made a quick project to test it out, just to be sure!
-c
A | B - it's not a choice.
|
|
|
|
|
You're a machine, I stand in awe.... All I did was type.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
It'd probably be fairly easy to make a bot that'd post random stupid VB questions, and nobody would probably ever notice - benjymous - 21-Jan-2003
|
|
|
|
|
You're not changing nWidth, you're changing the value stored in it. Why is nWidth a pointer ? When your function returns, it will still point to the same place.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
It'd probably be fairly easy to make a bot that'd post random stupid VB questions, and nobody would probably ever notice - benjymous - 21-Jan-2003
|
|
|
|
|
ok. I understand kind of.. even if a function is constant, it can still modify what a pointer points to.
|
|
|
|
|
MAybe this will help - if you create a pointer you can do this:
const int * p_i,
or this:
int * const p_i
the second syntax makes the value const, the first the memory address. A const function only enforces the first idea.
const int * const p_i is also valid syntax for both.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
It'd probably be fairly easy to make a bot that'd post random stupid VB questions, and nobody would probably ever notice - benjymous - 21-Jan-2003
|
|
|
|
|
Thank you. I understand what is going on. I don't want to keep asking stupid questions.. but if that is the case, then how would you solve this problem.
suppose you have a class, and this class has some pointers to different objects.. now some functions of the class need to be able to modify the data of what the pointer points too, but you also have some functions that just need to retrieve the data, and you want to make sure that those functions do not modify the pointed to data.
|
|
|
|
|
How about
int * const pTemp = m_pInt;
so in the function you always access a const pointer ? I can't think of an iron clad solution, i.e. one that does not rely on the functions implimenter 'playing by the rules'. Unless I have external clients, I don't use const functions much at all, and if you declare it const and don't modify anything, then the fact that you could is immaterial, you made a contract with your classes clients and you kept it.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
It'd probably be fairly easy to make a bot that'd post random stupid VB questions, and nobody would probably ever notice - benjymous - 21-Jan-2003
|
|
|
|
|
Thank you Christian. That was the answer I came up with, but with my limited experince, I just wanted to make sure.
|
|
|
|
|
const prevents the method from changing the value of any data members. In this case, it's the pointers. You're changing the value of what is being pointed to.
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
NEW: Awasu v0.7[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Taka Muraoka wrote:
const prevents the method from changing the value of any data members
Not quite. const is a contract, a promise, to not change the logical state of an object, when applied to a member function.
Imagine a class that has a backing store (e.g. a database) for the data it can present to the user. Any GetFoo() should probably be a const member function.
Later on you realize "Hey, this stuff is waaay to slow. I need a cache!". You implement such a cache. But, that would change the objects state, right? No. This is where the mutable keyword come in play.
A const member function may modify mutable qualified data - even that the "contract" you have with the clients of that code promises that it may not change the objects logical/observable state.
This is just scraping the top of the iceberg. Const correctness is an artform in itself, and depending on scope it can mean a whole lot of things.
For further information, I think Marshall Cline's C++ FAQ Lite could be a good starting point.
|
|
|
|
|
i would to retreive a handel of window of ACROBAT for PDF document ,and i don't know how to use FindWindow("?","?").can you help me
|
|
|
|
|
aguest wrote:
and i don't know how to use FindWindow("?","?").can you help me
Read this[^].
Nick Parker
The only man who never makes a mistake is the man who never does anything. - Theodore Roosevelt
|
|
|
|
|
Hi all,
I am new to encrypt and decrypt.
I want to encrypt/decrypt a fixed length small block of data. It is there any sample methord that don't need key?
Thanks
laura
|
|
|
|
|
add 128 to each byte. that's about as secure as you can get, without using a key of some kind.
-c
A | B - it's not a choice.
|
|
|
|
|
Chris Losinger wrote:
add 128 to each byte. that's about as secure as you can get, without using a key of some kind
But wouldn't 128 be a sort of a key too?
--
karl
|
|
|
|
|
Would someone help me by telling me why this doesnt work? I'm trying to write an easy way for me and my co-admins to change users passwords w/o using the standard tools. Note, that the DC= parts reflect my current Active Directory DC on my test machine. I know for a fact that the user I am requesting is at CN=UserName,CN=Users,DC=HOME,DC=Local.
void CChangePWDDlg::OnChangepw()
{
CString sUID, sPassword, sPWConfirm;
GetDlgItemText(IDC_USERID, sUID);
GetDlgItemText(IDC_PASSWORD, sPassword);
GetDlgItemText(IDC_PWCONFIRM, sPWConfirm);
if (sUID.GetLength() == 0)
{
AfxMessageBox("User ID cannot be empty");
return;
}
if (sPassword.GetLength() == 0)
{
AfxMessageBox("Password cannot be empty");
return;
}
if (sPWConfirm.GetLength() == 0)
{
AfxMessageBox("Re-Enter Password");
return;
}
if (strcmp(sPassword, sPWConfirm) != 0)
AfxMessageBox("Passwords Don't Match");
else
{
CString objPath = "LDAP://CN=";
objPath = objPath += sUID;
objPath = objPath += ",CN=Users,DC=HOME,DC=Local";
BSTR oPath = objPath.AllocSysString();
IADsUser *pUser;
HRESULT h2;
h2 = ADsGetObject(oPath, IID_IADsUser, (void**) &pUser);
if (FAILED(h2))
{
AfxMessageBox("Failed to get user");
SysFreeString(oPath);
pUser->Release();
return;
}
else
{
SysFreeString(oPath);
BSTR oPass = sPassword.AllocSysString();
HRESULT hr;
hr = pUser->SetPassword(oPass);
pUser->Release();
if (FAILED(hr))
{
AfxMessageBox("Failed to set password");
return;
}
else
{
SetDlgItemText(IDC_USERID, "");
SetDlgItemText(IDC_PASSWORD, "");
SetDlgItemText(IDC_PWCONFIRM, "");
}
}
}
}
I always receive "Failed to get user".
Thanks,
Frank
PS. Alot of this code was used from examples on MSDN.
|
|
|
|
|
Hello guru's around the world!
I'm writing some software to handle some simple home-made hardware under windows2000.
I need to use 2 input and 2 output channels, being: DSR, CTS, RTS, DTR. I open the serial port using CreateFile(..) , non overlapped. Toggleing the output channels with EscapeCommFunction(..) works fine too.
A worker tread is in an infinite loop (while(true)) in which it waits for a WaitCommEvent(..) . When the DSR or the CTS lines change state, I get notified - just as it should be.
But I want to keep polling with WaitCommEvent(..) and I want to use EscapeCommFunction(..) to toggle the output lines.
To be more exact, I need to be able to give pulses to the DTR and watch what happens to the CTS (input). Unfortunatly, EscapeCommFunction(..) hangs if WaitCommEvent(..) is still waiting for an event.
Do I NEED to use overlapped IO for this? Or is it possible to change the DTR status while polling the CTS?
Thanks in advance,
Regards,
Griffith Sutherns
Everything you say will be misquoted, ripped out of context and used against you.
|
|
|
|
|
In non-overlapped IO each call will block the IO resource.
You will also run into problems when you try to exit from your thread because it will be stuck on WaitCommEvent.
You have a couple of choices:
1. Don't use WaitCommEvent and instead poll the IO with GetCommModemStatus.
Polling can be OK if done infrequently.
2. Use overlapped IO. A little more complicated but it won't block the IO resource.
I'd go with overlapped IO.
Col
|
|
|
|
|
Thanks a lot Colin!
I'll look into GetCommModemStatus first, that might just be what I was looking for. Although I do need need to poll about 80 times in a few seconds, it might still work reliably.
Once again, your help's greatly appriciated.
Regards,
Griffith
Everything you say will be misquoted, ripped out of context and used against you.
|
|
|
|
|
BTW,
Since you plan to poll you should do it at least double the maximum possible expected input frequency to ensure you do not miss a pulse.
Col
|
|
|
|
|
I use visual studio.net enterprise architect
I'm coding an app with MFC.
I have a problem. After including some source directory (containing *.inl) into the include path of the project properties, VS.net crash when I use project -> 'add ressource'.
Any Ideas?
Everything's beautiful if you look at it long enough...
|
|
|
|
|
why this routine stops everytime with the errorMessageBox??
thx for help.
m_Path: absolute path to the file (for example "c:\data\test.log"
void CTestDlg::OnOK()
{
this->UpdateData(true);
CString error;
CStdioFile logFile;
CFileException fileException;
if (!logFile.Open( m_Path, CFile::modeRead ),
&fileException )
{ //ERROR
error.Format( "Can't open file %s, error = %u\n",
m_Path, fileException.m_cause );
MessageBox(error,NULL,MB_OK);
}
else
{ //all okay
logFile.Close();
}
CDialog::OnOK();
}
|
|
|
|
|
what does fileException.m_cause contain?
-c
A | B - it's not a choice.
|
|
|
|
|
the errorcode...
but i think i found the problem...
its strange... 1 day searching without success
and some minutes after this post i found a wrong placed ")"
in the if-cause ...
the ")" should be after the exception-var...
|
|
|
|
|
Hello,
I have some really simple wininet code that performs and http post and closes the handles when done. I am having a problem where on app exit, I perform a final http post and close all of my handles without fail and exit my wininet function, but the app refuses to unload until after a 60 second pause. Any ideas why?
|
|
|
|