|
I only browsed through it quickly, but my impression was that CreateMutex won't work as solid as you would think. I totally didn't even think of multitasking.
Thats for the tip...
I'll be sure to read up on it, so as not to offer insufficient advice.
Ah well there loss not mine!
Cheers
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Use this class:-
class CLimitSingleInstance
{
protected:
DWORD m_dwLastError;
HANDLE m_hMutex;
public:
CLimitSingleInstance(TCHAR *strMutexName)
{
m_hMutex = CreateMutex(NULL, FALSE, strMutexName);
m_dwLastError = GetLastError();
}
~CLimitSingleInstance()
{
if (m_hMutex)
{
CloseHandle(m_hMutex);
m_hMutex = NULL;
}
}
BOOL IsAnotherInstanceRunning()
{
return (ERROR_ALREADY_EXISTS == m_dwLastError);
}
};
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
While I was coding a fileparser I stubled upon something _very_ weird. My file started like this (in hex):
020102416E6369656E74277320506C6564676501536869656C64730152616C034F72740354616C012B353025
20456E68616E63656420446566656E736504436F6C6420526573697374202B34332504466972652052657369
7374202B343825044C696768746E696E6720526573697374202B34382504506F69736F6E2052657369737420
2B343825043130252044616D61676520476F657320546F204D616E6100426C61636B01436C7562730248616D Try pasting this into a new file using a hexeditor, save it, and then open it in Notepad. If you have chinese character-set installed it will for some reason show up in chinese. Why?! This is mostly plain english... I've tested this lots of times, and there seems to be no way around it, except uninstalling the chinese character set!
Sprudling
PS! I'm using WindowsXP Pro
|
|
|
|
|
Have you checked for virii lately ?
|
|
|
|
|
As a matter of fact I just did earlier today. Using NAV 2002 with the most up to date virus definitions, and no virus found.
I really think there is a logical explanation to this.
Sprudling
|
|
|
|
|
You are probably right. I was grasping at straws.
|
|
|
|
|
Check your Notepad default font settings
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
That was of course the first thing I checked and it's the WinXP default courier. It's only that file (and others starting with the same numbers in hex) that shows up in chinese. Have any of you even tested yet?
Sprudling
|
|
|
|
|
What is the file extension you are using?
The way I understand notepad is that if the extension is TXT it simply reads the file as ASCII and dumps it on the multi line edit control which is it's main control.
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
The extension doesn't matter. I can rename the file to whatever I want, and it shows the same chinese signs. Anyway, I think I've figured out why this happens how. Then the WinXP parses a file it tries to find out if it's ASCII or Unicode.
An experiment:
- Create a new .txt file in Notepad, enter "Sprudling", and save it as usual.
- Open the file in an hexeditor and insert 2 bytes in front og "Sprudling".
- Set the 2 bytes to FFFE, and save the file again.
- Now open it again in Notepad.
It's now shown in unicode as "灓畲汤湩", which is 4 chinese letters for those who actually have installed those letters. I guess Notepad is more than you thought... :]
Sprudling
|
|
|
|
|
Yeah. Tim Smith cleared that up for me
But he says he's getting old
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Probably what is happening is that Notepad is using an auto-detect to see what encoding you are using. With those binary characters at the start, it is getting fooled into thinking it is something like UTF-16 (or whatever they call UNICODE).
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
I seriously doubt that Notepad does anything of that sort. It's only functionality is to open the file and read the contents into a multi line edit control.
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
BZZZZZ....
Wrong.
Save something from Notepad. On the save dialog you get to select the encoding. Now, since there is no magical encoding flag in the file system, that information has to be stored in the file.
When you open a file in notepad, it goes through some nasty work to try figure out the encoding. For example, UTF-16 can commonly be detected by looking for alternating 0 bytes.
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
Oh Boy!!!
Thanks Tim S. Thanks for the info.
But this is bad. This means notepad is not a pure text editor anymore. Now what do we do? Windows comes with not a single pure text editor.
Do we all have to go back to the COPY CON days???
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
heh...
COPY CON
Been there, done that.
GOD I AM GETTING OLD!!!
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
Tim Smith wrote:
GOD I AM GETTING OLD!!!
Yes, I agree
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
You could always use edit.com
Sprudling
|
|
|
|
|
edit.com was introduced with DOS 5.0 [it was part of the qbasic set]
later it became stand-alone
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
You can use IsTextUnicode and see what it returns. This is probably what notepad does..
/moliate
|
|
|
|
|
According to the Microsoft "What's New In MFC7" information (that I've seen some time ago on the net), it is possible to enable standard Windows/MFC application to consume Web Services. Has somebody seen any sample/code or detailed technical article about the topic? Thanks.
Dejan Petrovic
|
|
|
|
|
I have a service that appears to eat memory at a pretty steady rate. If I bring up Task Manager, I can watch the Virtual Memory (and real memory) counter climb steadily.
In trying to solve the problem I used the CRT library to checkpoint the memory periodically. This technique has allowed me to find and fix several leaks.
Now, however, the CRT library machines are telling me there are no more leaks, while the task manager says there are still some left (real and VM still rises steadily). Following the example in MSDN, I've declared 3 _CrtMemState variables as globals (s1, s2, s3).
My app does a check point into s1 and then sets a timer.
When the timer goes off, the handler executes and then does another checkpoint into s2. The two checkpoints are compared into s3 and the result reported, as usual. The report shows differences in allocated memory between s1 and s2, as you would expect. The interesting part is that none of the allocation numbers change, while the Task manager keeps saying I'm eating memory!!
I know the checkpointing is working because the display shows a higher total allocations count each time.
Any ideas would be appreciated.
Here's the code I'm using for the checkpoints.
_CrtMemState s1, s2, s3;
_CrtMemCheckpoint(&s1);
::SetTimer(NULL, NULL, 1, OnPollTimer );
VOID CALLBACK OnPollTimer( HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime )
{
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
_Module.m_bProcessRunning = TRUE;
::KillTimer(hwnd, idEvent);
DoPollTimer();
TRACE0(_T("OnPollTimer 1\r\n"));
_CrtMemCheckpoint(&s2);
_CrtMemDifference(&s3, &s1, &s2);
_CrtMemDumpStatistics(&s3);
TRACE0("----------------------------------------------------------\r\n");
::SetTimer(NULL, NULL, g_lPollFreqSecs * SECOND, OnPollTimer );
_Module.m_bProcessRunning = FALSE;
}
I don't have access to the server right now, so I can't provide a sample of the output. It shows some memory allocated as normal, client and CRT. The numbers don't change from one iteration to the next.
Any ideas would be greatly appreciated.
Thanks for the help,
Bill
|
|
|
|
|
(Some of my information might be outdated...)
Those routines can only check for memory managed by the C runtime library (this is where I could be wrong if they have changed how this works.)
Thus, things like ATOMs, heap allocations, native WIN32 allocations, etc can all still be leaking. Are you creating a bunch of GDI objects and not properly destroying them?
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
My app is a service running on NT. It has no UI, so I don't think its a GDI leak. Do you have any suggestions on how to detect/isolate the other possiblities for leaks?
I don't know how to monitor the rest of the memory usage.
Thanks for the help,
Bill
|
|
|
|
|
InsertItem don't work :
void CMyListView::OnInitialUpdate()
{
CListView::OnInitialUpdate();
ModifyStyle(NULL, LVS_REPORT,0);
// this code only works for a report-mode list view
//ASSERT(GetStyle() & LVS_REPORT);
// Gain a reference to the list control itself
CListCtrl& theCtrl = GetListCtrl();
// Insert a column. This override is the most convenient.
theCtrl.InsertColumn(0, _T("Names"), LVCFMT_CENTER);
// The other InsertColumn() override requires an initialized
// LVCOLUMN structure.
LVCOLUMN col;
col.mask = LVCF_FMT | LVCF_TEXT;
col.pszText = _T("Version");
col.fmt = LVCFMT_CENTER;
theCtrl.InsertColumn(1, &col);
theCtrl.InsertColumn(2,"Description",LVCFMT_CENTER);
// Set reasonable widths for our columns
theCtrl.SetColumnWidth(0, 200);
theCtrl.SetColumnWidth(1, 100);
theCtrl.SetColumnWidth(2, 100);
GetListCtrl().InsertItem(0, "First row"); //Don't work ??
// TODO: You may populate your ListView with items by directly
//accessing
// its list control through a call to GetListCtrl().
}
Please Help Me ,thanks
|
|
|
|