|
Actually it would be better to use strncmp instead of strcmp because then you specify the number of characters to compare so it would return correctly if the string contained "0 cars" also you would want to trim out the spaces in the string first before the compare in case you had a string " 0 cars" so that it would return correctly as well.
|
|
|
|
|
Appreciate the explanation and the nifty way to handle it.
Many thanks,
ns
|
|
|
|
|
I usually use isdigit() to test for such things.
Calling a function that carries out an operation that you have no intent on using just to see if it returns an error isn't typically considered good design.
|
|
|
|
|
For example:
'D:\Documents and Settings\Grrrr\My Documents'
In VC++6.0, which function or API or Class can do this?
Thanks a lot...
|
|
|
|
|
use SHGetSpecialFolderPath
|
|
|
|
|
This method is the simplest method??
Just now, I have read this function in MSDN.
I found it use Shell...
I thought there have a simple mothod, I thought we can get the path-name
direct, use a API. as 'GetSystemDirectory'.
I'm sorry.perhaps i am wrong.
|
|
|
|
|
|
HEY LOOK I THE FAQ SECTION I SAW THIS THERE GOOD LUCK
H43K4Z
|
|
|
|
|
I'm still a green horn in the area of COM and I have some business object classes I want to put in a com server(either DLL or EXE).How do I achieve this using wizards and Compiler COM support(attributes etc.)?
I've been using MFC for some time now.
What would life be without politicians and programmers?
|
|
|
|
|
I think that your topic might be beyond the scope of the forums, but a good place to start is "Beginning ATL 3 COM" ISBN: 1861001207 and "Professional ATL COM Programming" ISBN: 1861001401 if you can still find them. They are a great start and cover using COM and developing COM objects in C++.
|
|
|
|
|
Hi, I've created a server using dialog which listens to any incoming client connections. here, while the server listens, it is blocked in an infinite loop while accepting connections. Now I want the server to create a new thread for every connection with a new client. how can I do this.
Also, I cannot write the thread handler as a member function of a class. how can i do that?
Shenthil
|
|
|
|
|
Shenthil wrote:
Now I want the server to create a new thread for every connection with a new client.
Really? Are you sure you want that many potential threads/connections? Have you considered a thread pool?
Shenthil wrote:
Also, I cannot write the thread handler as a member function of a class. how can i do that?
Use a static member.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
One solution is a non-blocking I/O model. In such a design, a process only needs one or two threads per CPU.
Kuphryn
|
|
|
|
|
hey,
does somebody know how to delete the kernel32.dll ?
Thanks in advance!
|
|
|
|
|
c:\> format c:
--
Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so. (Douglas Adams)
|
|
|
|
|
On all versions of Windows, you can't delete it while Windows is running because it's loaded into every process on the system. There is a way to get Windows to replace a file that's in use when it reboots, but in this case I'm not going to tell you because you're basically intending to break Windows.
Windows 2000, XP and Server 2003 will resist you by copying out of the DllCache, unless Windows File Protection is disabled. Even if it is, the next patch that replaces kernel32.dll will undo what you've done - or the next time that the user runs the System File Checker, it will ask for the Windows CD in order to repair the damage, since Windows also keeps a signed catalogue of the file versions of protected files.
I can't seem to make it clear to you that this is extremely stupid and you will have to find another route to achieve whatever you're trying to achieve - which you still haven't properly explained.
|
|
|
|
|
i know that there's a function called MoveFileEx, which moves or delets a file after reboot! But that won't work for kernel32.dll because movefileex IS part of the kernel32.dll!
If you know another method to change the kernel32.dll then please let me know how!
Thanks in advance!
|
|
|
|
|
|
I must ask that why would you wish to know ?
Like stated, kernel32.dll is a core component of Windows OS series. If it is deleted, moved or altered, it most likely causes the operating system to fail booting. On a non-DOS version of Windows (2000, NT, XP, 2003), this would result in a disastreous effect.
So... Once more, why do you want to delete it ? Are you, per chance, planning on some kind of a doomsday device ? A virus ? I sincerely hope not, because Code Project, as far as I know, was not made for mischievous people.
If you can reason why you'd need to alter it, perhaps we consider in assisting you. Other than that, you should consider another kind of approach to whatever you are trying to accomplish.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Why do you want to delete kernel32? It's a core OS component! Windows won't run without it!! You can't delete it probably because it's loaded into memory and is being used ... for the delete operation!
But if you insist... maybe you can try starting your machine in DOS mode (maybe with a DOS bootable floppy). That way windows won't have loaded it and you can then delete it (after disabling the readonly mode).
"It was when I found out I could make mistakes that I knew I was on to something."
-Ornette Coleman
|
|
|
|
|
Make a startup disk. Boot your machine using it. Now once you have booted in DOS mode you can go to the windows directory and delete kernel32.dll
del kernel32.dll
Somewhere in the world there is a machine language programmer waiting for that damned assembly language fad to pass. - Stan Shanon
|
|
|
|
|
I'm sure the answer to this will be obvious (about 5 seconds after I read the response) but I'm mightily puzzled by this...
I've derived a class from CFileDialog that looks like this...
class CLoadLogFilesDlg : public CFileDialog
{
DECLARE_DYNAMIC(CLoadLogFilesDlg)
public:
CLoadLogFilesDlg(BOOL bOpenFileDialog, LPCTSTR lpszDefExt = NULL, LPCTSTR lpszFileName = NULL, DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, LPCTSTR lpszFilter = NULL, CWnd* pParentWnd = NULL);
~CLoadLogFilesDlg();
protected:
virtual void DoDataExchange(CDataExchange* pDX);
virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
private:
CStringList m_slFileList;
protected:
virtual BOOL OnFileNameOK();
virtual void OnOK();
afx_msg void OnLoadAll();
afx_msg void OnLoadToday();
DECLARE_MESSAGE_MAP()
};
and the class implementation is this...
IMPLEMENT_DYNAMIC(CLoadLogFilesDlg, CFileDialog)
CLoadLogFilesDlg::CLoadLogFilesDlg(BOOL bOpenFileDialog, LPCTSTR lpszDefExt, LPCTSTR lpszFileName, DWORD dwFlags, LPCTSTR lpszFilter, CWnd* pParentWnd) : CFileDialog(bOpenFileDialog, lpszDefExt, lpszFileName, dwFlags, lpszFilter, pParentWnd)
{
CString csInitDir;
TCHAR szWinDir[_MAX_PATH + 1];
m_ofn.lStructSize = sizeof(OPENFILENAME);
m_ofn.Flags |= OFN_ENABLETEMPLATE | OFN_ALLOWMULTISELECT;
m_ofn.hInstance = AfxGetInstanceHandle();
m_ofn.lpTemplateName = MAKEINTRESOURCE(IDD_LOADLOGS);
GetWindowsDirectory(szWinDir, _MAX_PATH);
csInitDir.Format(_T("%s\\%s"), szWinDir, COMMANDPIPENAME);
m_ofn.lpstrInitialDir = csInitDir;
m_ofn.lpstrFile = new TCHAR[10000];
m_ofn.nMaxFile = sizeof(m_ofn.lpstrFile);
memset(m_ofn.lpstrFile, 0, sizeof(m_ofn.lpstrFile));
}
CLoadLogFilesDlg::~CLoadLogFilesDlg()
{
delete m_ofn.lpstrFile;
}
void CLoadLogFilesDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BOOL CLoadLogFilesDlg::OnFileNameOK()
{
return FALSE;
}
BOOL CLoadLogFilesDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
OFNOTIFY* pNotify = (OFNOTIFY*) lParam;
TRACE("pNotify->hdr.code == %x\n", 0 - pNotify->hdr.code);
if (pNotify->hdr.code == CDN_FILEOK)
return OnFileNameOK();
return CFileDialog::OnNotify(wParam, lParam, pResult);
}
BEGIN_MESSAGE_MAP(CLoadLogFilesDlg, CFileDialog)
ON_COMMAND(IDC_LOADALL, OnLoadAll)
ON_COMMAND(IDC_LOADTODAY, OnLoadToday)
END_MESSAGE_MAP()
void CLoadLogFilesDlg::OnLoadAll()
{
}
void CLoadLogFilesDlg::OnLoadToday()
{
CString csPattern;
csPattern.Format(_T("%s\\*.log"), m_ofn.lpstrInitialDir);
CFileFind ff;
BOOL bWorking = ff.FindFile(csPattern);
while (bWorking)
{
bWorking = ff.FindNextFile();
m_slFileList.AddHead(ff.GetFilePath());
}
CFileDialog::OnOK();
}
void CLoadLogFilesDlg::OnOK()
{
CFileDialog::OnOK();
}
The problem is that I never ever see a call to CLoadLogFilesDlg::OnFileNameOK() even though it's an override of a virtual function. When I see calls to the overridden OnNotify function the trace output is
pNotify->hdr.code == 25b
pNotify->hdr.code == 25a
pNotify->hdr.code == 25a
now when we look at the CFileDialog::OnNotify() function we find this code...
BOOL CFileDialog::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
ASSERT(pResult != NULL);
if (CCommonDialog::OnNotify(wParam, lParam, pResult))
return TRUE;
OFNOTIFY* pNotify = (OFNOTIFY*)lParam;
switch(pNotify->hdr.code)
{
case CDN_INITDONE:
OnInitDone();
return TRUE;
case CDN_SELCHANGE:
OnFileNameChange();
return TRUE;
case CDN_FOLDERCHANGE:
OnFolderChange();
return TRUE;
case CDN_SHAREVIOLATION:
*pResult = OnShareViolation(pNotify->pszFile);
return TRUE;
case CDN_HELP:
if (!SendMessage(WM_COMMAND, ID_HELP))
SendMessage(WM_COMMANDHELP, 0, 0);
return TRUE;
case CDN_FILEOK:
*pResult = OnFileNameOK();
return TRUE;
case CDN_TYPECHANGE:
OnTypeChange();
return TRUE;
}
return FALSE; }
and if we look at the definitions of the case labels we find they're
#define CDN_LAST (0U-699U)
#define CDN_INITDONE (CDN_FIRST - 0x0000)
#define CDN_SELCHANGE (CDN_FIRST - 0x0001)
#define CDN_FOLDERCHANGE (CDN_FIRST - 0x0002)
#define CDN_SHAREVIOLATION (CDN_FIRST - 0x0003)
#define CDN_HELP (CDN_FIRST - 0x0004)
#define CDN_FILEOK (CDN_FIRST - 0x0005)
#define CDN_TYPECHANGE (CDN_FIRST - 0x0006)
#define CDN_INCLUDEITEM (CDN_FIRST - 0x0007)
it's pretty obvious that the notification codes my dialog procedure is seeing don't match any of those constants which is why I'm not seeing calls to my overrides. I have no idea why? Any ideas?
Rob Manderson
http://www.mindprobes.net
"I killed him dead cuz he was stepping on my turf, cutting me out of my bling the same way my ho cuts cookies, officer"
"Alright then, move along" - Ian Darling, The Lounge, Oct 10 2003
|
|
|
|
|
Looks ok to me. I've compared your code with code I've written for ED and it is much the same. Why are you overiding OnNotify() though. Your OnFileNameOK() will be called by the framework without you doing this. I have a note in my code: "Note that OnFileNameOK() isn't called if the edit control is empty". Don't know if this is relevant.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Thanks Neville. I didn't know that OnFileNameOK() isn't called if the edit control is empty - add that one to the background pile
I'm overriding OnNotify() just so's I can see the notification codes pass by. I've fixed the couple of things Igor pointed out - the second one was setting the m_ofn.nMaxFile member to 4 instead of the buffer size. Once I did that I've started seeing OnFileNameOK() being called if I select a file and hit ok. The dialog still isn't working the way I'd like but I imagine some spelunking in MFC internals (always good for the soul ) will reveal why.
Rob Manderson
http://www.mindprobes.net
"I killed him dead cuz he was stepping on my turf, cutting me out of my bling the same way my ho cuts cookies, officer"
"Alright then, move along" - Ian Darling, The Lounge, Oct 10 2003
|
|
|
|
|
I maybe wrong here, and it's not really a problem, but please check yours CLoadLogFilesDlg constructor:
That sequence:
CLoadLogFilesDlg::CLoadLogFilesDlg(...<br />
...<br />
CString csInitDir;<br />
...<br />
m_ofn.lpstrInitialDir = csInitDir; <br />
... <br />
}
After constructor exits m_ofn.lpstrInitialDir will point to somewhere in the heap that just got released on destruction of csInitDir.
Just 2 cents...
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|