|
Thanks alot, it was helpful
|
|
|
|
|
Hi,
The CSocket class has been widely publicised as being buggy: the advice has historically been to use a 3rd party control or write your own.
Has the CSocket class with MFC supplied with VS2008 been updated, or is the current advice to use a 3rd party control / write your own?
Can anyone reccommend a 3rd party / free TCP wrapper? (Yes I'm aware there are plenty of example applications here on CP, but which one is the best)
thanks,
Mark.
|
|
|
|
|
|
I don't know how buggy it is - it does what it's documented to do.
It's a very simple designed wrapper around the Winsock APIs. It
works fine for simple socket tasks (on one thread).
If you need performance you'll need asynchronous communications.
You can use the CAsyncSocket - it works pretty well and it's a very
thin wrapper around the socket APIs so you could use straight APIs
almost as easily.
The important thing is to know how sockets work and how to use the APIs.
Then the MFC classes will make more sense and you'll be able to use them
effectively. The source code for those classes is the ultimate documentation,
and it's relatively easy to read.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I am trying to set 404 custom error page on windows 2003.
then I restarted the IIs but it fails
In IIS
1. I am selecting the properties of the website
2. selecting Custom errors Tab
3. Then selecting the new custom error page
4. then restarting the IIS
But This procedure fails ...
pls help me
|
|
|
|
|
i have wrote code logon admin in limited user like the following
****************************************************************
BOOL CEKLoaderDlg::OnLogonUser()
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
HANDLE hToken;
LPCTSTR lpszPrivilege = "SeTcbPrivilege";
BOOL bEnablePrivilege = TRUE;
BOOL bDisEnablePrivilege = FALSE;
LPDWORD lpExitCode;
char* username = "administrator";
char* password = "xxx";
char* cmdLine = "cmd.exe";
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
static LUID luid;
static TOKEN_PRIVILEGES tp;
if(!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken))
{
AfxMessageBox("OpenProcessToken() error \n");
}
else
// AfxMessageBox("OpenProcessToken() is OK\n");
//********************* Enabling (Disabling) privilege ***************************
// Call the user defined SetPrivilege() function to enable privilege
if( SetPrivilege(hToken, lpszPrivilege, bEnablePrivilege))
{
if(LogonUser(username,".",password,LOGON32_LOGON_INTERACTIVE,LOGON32_PROVIDER_DEFAULT,&hToken))
{
if(ImpersonateLoggedOnUser(hToken))
{
if(CreateProcessAsUser(hToken,0,cmdLine,0,0,FALSE,NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW,0,0,&si,&pi))
{
// editbootini();
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
TerminateProcess(hToken,0);
return TRUE;
}
else
{
AfxMessageBox("Failed");
}
// Cleanup...
if( pi.hProcess != NULL )
CloseHandle( pi.hProcess );
if( hToken != NULL )
CloseHandle( hToken );
}
}
else
{
AfxMessageBox("Administrator password is wrong");
exit(0);
}
}
SetPrivilege(hToken, lpszPrivilege, bDisEnablePrivilege);
return TRUE;
}
Then wrote code for restart like the following
*********************************************
m_stcCalling.SetWindowText("Restarting Your System");
AfxEnableControlContainer();
HANDLE hToken; // handle to process token
TOKEN_PRIVILEGES tkp; // pointer to token structure
BOOL fResult;
if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
*******************************************//return failure
{
log("Error Type : Error in Restarting");
log("Severity Level : Critical");
return FALSE;
}
// Get the LUID for shutdown privilege.
LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
&tkp.Privileges[0].Luid);
tkp.PrivilegeCount = 1; // one privilege to set
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
// Get shutdown privilege for this process.
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
(PTOKEN_PRIVILEGES) NULL, 0);
fResult =InitiateSystemShutdown(NULL, "System is being restarted ", 0, TRUE, TRUE);
if (!fResult)
{
fResult = GetLastError();
log("Error Type : Restarting Failed");
log("Severity Level : Critical");
return FALSE;
}
return 1;
}
But restart wont done .why?
|
|
|
|
|
Please indent the code and use appropriate tags for the code blocks. It is very difficult to read your code.
Regards,
Sandip.
|
|
|
|
|
What function is failing? Have you bothered to use the debugger to find out what is going on?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
When I delete the code of a class's menber function, the class view cann't flash, why?
Thanks!
|
|
|
|
|
Why would the "class view" flash?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hi all,
I have made a application on VC-2005. Now my problem is its not working on windows-2003, i.e when i click on exe nothing happens...
Why my exe is not working on windows-2003...
Can anybody help me in this?
Thanks in advance
|
|
|
|
|
|
|
Try installing it. That installation is necessary if we want to run a VS 2005 exe in a OS where Visual studio 2005 is not installed.
Also confirm that you are trying to run the release version of the binaries.
|
|
|
|
|
Naveen wrote: That installation is necessary if we want to run a VS 2005 exe in a OS where Visual studio 2005 is not installed.
Isn't it sufficient to create an installation along with necessary dlls found in the Program Files\Microsoft Visual Studio 8\VC\redist\x86 folder?
Have you tried out this way? Just curious.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
I havent tried that way. Since those binaries are implemented as side-by-side assemblies, I guess it will be little difficult to include them in the installation.
|
|
|
|
|
I am making a chat application. I need to send & recieve emoticons/smileys. I am getting their codes. What to do to retireve the smileys properly
Thanks In advance
Dhiraj
|
|
|
|
|
What do you mean exactly ? Emoticons are just a specific combination of symbols (e.g. : and ) ). Those symbols are then interpreted by your application and replaced by a small image representing the emoticon. But you have to do that yourself.
|
|
|
|
|
Thanx! I will try to do it.
|
|
|
|
|
Hi all,
I have made a simple text file using CStdioFile object and writing and reading strings using that file and saved it using different file extension suppose .ehn. Now i want to hide this file i.e it must be shown when i click on folder option show hidden files and folder...
how can i do this......
thanks in advance
|
|
|
|
|
Use the api - SetFileAttributes() by passing FILE_ATTRIBUTE_HIDDEN as parameter.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
|
I have a dialog-based application that contains a combo box.
I've subclassed the combo box like this :
HBRUSH CSubClassedComboBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
if (nCtlColor == CTLCOLOR_EDIT)
{
if (m_CmbEditBox.GetSafeHwnd() == NULL)
m_CmbEditBox.SubclassWindow(pWnd->GetSafeHwnd());
}
else if (nCtlColor == CTLCOLOR_LISTBOX)
{
if (m_CmbListBox == NULL)
{
m_CmbListBox = new CListBoxEx;
if (m_CmbListBox->GetSafeHwnd() == NULL)
{
m_CmbListBox->SubclassWindow(pWnd->GetSafeHwnd());
}
}
}
HBRUSH hbr = CComboBox::OnCtlColor(pDC, pWnd, nCtlColor);
return hbr;
}
m_CmbEditBox and m_CmbListBox are objects of CEdit and CListBoxEx(derived from CListBox) respectively
and declared in SubClassedComboBox.h as the class CSubClassedComboBox's members.
During run-time of my application, I pull down the list box and right-click on any of the
list box items. My control reaches here :
void CListBoxEx::OnContextMenu(CWnd* pWnd, CPoint point)
{
GetParent->TestFn();
}
Now, in CListBoxEx::OnContextMenu, I want to call a member function ( say TestFn() ) available in class CSubClassedComboBox.
Please see the following code :
void CListBoxEx::OnContextMenu(CWnd* pWnd, CPoint point)
{
((CSubClassedComboBox *)GetParent())->TestFn();
GetParent())->TestFn();
}
As in the comments, the second statement doesn't work. I don't want to cast the pointer returned
by GetParent() to CSubClassedComboBox * bcoz this wouldn't be in generic sense.
By this, I mean to say that GetParent() should be able to give the parent pointer which is
CSubClassedComboBox * in this case, but could be anything else (eg. another container window that contains
the CListBoxEx object).
In summary,
GetParent()->TestFn(); should call TestFn() of CSubClassedComboBox as per the requirement above.
But GetParent())->TestFn(); should be able to call TestFn() of say CSubClassedSomeContainerWindow
if m_ListBox is a member of CSubClassedSomeContainerWindow
So, I am looking for a solution that is generic, to find the parent.
Any help would be appreciated.
Thanks in advance.
|
|
|
|
|
SherTeks wrote: So, I am looking for a solution that is generic, to find the parent.
If I understood your question properly...
Define a message for your parent class, for e.g. WM_TEST_FN . So all the parent needs to do is define a handler for this message. So if the handler is there then the function will be called.
So then you can use SendMessage to send this message.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
ok. You won this time
|
|
|
|