|
Nope, but thanks for the suggestion. What is truly odd, is that the problem happens only on SOME machines. They are all running W2K SP2. Some are single processor PIIIs, others are dual processor Xeons. However, another machine (an Althon 1900+) doesn't seem to be able to replicate the problem. (Although it is running SP3) Odd...
|
|
|
|
|
Turns out this problem only seems to occur on dual processor or dual processor CAPABLE machines. I have generated some sample code which exhibits the problem. If anyone can tell me why this happens or if there is a "workaround" which doesn't involve changing code, I'd be grateful. I do know that one change that makes this work is calling timeBeginPeriod/timeEndPeriod ONCE per instance of the application rather than repeatedly, but I can't change the code in question.
Sample code at:
http://gstark.home.mindspring.com/MultiMediaTimerBug.cpp [^]
#pragma comment( lib, "Winmm.lib" )
#include <process.h>
#include <windows.h>
#include <stdio.h>
const UINT kSleepyTimeMilliseconds = 300;
void CALLBACK Win32MultiMediaTimerProc(UINT wTimerID, UINT msg, DWORD dwUser, DWORD dw1, DWORD dw2)
{
}
unsigned __stdcall Win32_MyThreadProcStdC(void* threadInput_i)
{
while( TRUE )
{
MMRESULT result;
TIMECAPS timeCapabilities;
result = ::timeGetDevCaps(&timeCapabilities,sizeof(timeCapabilities));
if (result != TIMERR_NOERROR)
return 0;
UINT myWin32TimerResolution = timeCapabilities.wPeriodMin;
if (timeCapabilities.wPeriodMax < myWin32TimerResolution)
myWin32TimerResolution = timeCapabilities.wPeriodMax;
if (myWin32TimerResolution < 1)
myWin32TimerResolution = 1;
result = ::timeBeginPeriod(myWin32TimerResolution);
register UINT timerOptions = TIME_CALLBACK_FUNCTION
| TIME_PERIODIC;
MMRESULT myWin32MultiMediaTimerID = ::timeSetEvent(
(UINT)500,
myWin32TimerResolution,
Win32MultiMediaTimerProc,
(DWORD)0,
timerOptions
);
DWORD lastWin32Error = ::GetLastError();
FILE* f = fopen( "trashFile","w");
if( f )
{
fprintf(f, "trash\n" );
fclose(f);
}
::Sleep( kSleepyTimeMilliseconds );
for( UINT i = 0; i < kSleepyTimeMilliseconds; i++ )
{
::Sleep( 0 );
}
result = ::timeKillEvent( myWin32MultiMediaTimerID );
lastWin32Error = ::GetLastError();
UINT killRetryCount = 3;
while( ( result != TIMERR_NOERROR )
&& ( killRetryCount > 0 ) )
{
::Sleep(0);
result = ::timeKillEvent( myWin32MultiMediaTimerID );
lastWin32Error = ::GetLastError();
if( ( result != TIMERR_NOERROR )
&& ( lastWin32Error == ERROR_ALREADY_EXISTS ) )
{
result = TIMERR_NOERROR;
lastWin32Error = 0;
}
killRetryCount--;
}
switch (result)
{
case TIMERR_NOERROR:
break;
case MMSYSERR_INVALPARAM:
return 0;
case TIMERR_NOCANDO:
break;
default:
break;
}
result = ::timeEndPeriod(myWin32TimerResolution);
::Sleep( kSleepyTimeMilliseconds );
}
}
void ThreadTest()
{
const UINT kNumberThreads = 10;
for( UINT i = 0; i < kNumberThreads; i++ )
{
unsigned threadID;
const unsigned long threadResult = _beginthreadex(
NULL,
0,
Win32_MyThreadProcStdC,
NULL,
0,
&threadID
);
}
while( TRUE )
{
::Sleep( 1000 );
}
}
int main(int argumentCount_i,
const char* const argumentValueArray_i[])
{
ThreadTest();
return 0;
}
|
|
|
|
|
Hi,
Let say I have a VC++ application and try to retrieve a data from an external "c:\file.mdb":
- Its Password is: PASSWORD
- It has two tables: Table1, Table2
- In Table1: it has two column titles: ID, Data
After I use:
<br />
CDaoDatabase *pdb;<br />
<br />
pdb = new CDaoDatabase; <br />
pdb->Open ("c:\file.mdb", FALSE, FALSE, ";PWD = PASSWORD");<br />
How can I retrieve in Table1 the Data at a specific row by knowing the its ID, by the way let assume all fields are Text
Anyone can help me?
Many thanks
|
|
|
|
|
You are asking if you can open the file using C (not the database driver / server) or whatever language and search for the ID?
John
|
|
|
|
|
Hi,
I am using Visual C++ 6.0 project and through it I am trying to open a MicroSoft Access database file.mdb of an existed database from someone esle ... but I do know its environment (I do not have its class in my project)
*) Please verify my original request, it has more detail
Thanks
|
|
|
|
|
Hi all,
please see the code below:
//add single doc template
..........
//process command line
CNewCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
if(!cmdInfo.m_bHasTasks)
{
m_pMainWnd->ShowWindow(SW_SHOWNORMAL);
m_pMainWnd->UpdateWindow();
}
else
{
m_pMainWnd->ShowWindow(SW_HIDE);
DoCommandLine(cmdInfo);
return FALSE;
}
Here, when i call showindow(SW_HIDE), the window first appears and then disappears. How can i prevent this flicker ? I must create the window BTW.
regards
hari
Hari Krishnan
|
|
|
|
|
For example,
Class CA{
...
int m_member;
...
}
Class CB{
instance=new CA;
}
Now I want to get CA.m_member's pointer in Class CB, how should I do?
|
|
|
|
|
int* p = &(instance.m_member);
John
|
|
|
|
|
It is wrong.
Don't add "&()";
Only add (*int) in advance.
that is:
(int *)CA.member
|
|
|
|
|
That is a cast operator, not the address of operator.
&CA.member is correct.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Tim Smith wrote:
I'm going to patent thought. I have yet to see any prior art.
How true in this case
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
You have a pointer to a CA object, so use the -> operator to access the CA members:
int n = instance->m_member;
--Mike--
"So where does that leave us? Well, it leaves us right back where we started, only more confused than before." -- Matt Gullett
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|
I want to get the member's pointer, not its value.
|
|
|
|
|
|
John M. Drescher already gave you the correct answer.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
Thanks. I had no clue how my answer could be wrong...
John
|
|
|
|
|
What do you mean by the members pointer??? The members address???? A pointer to m_member???
instance->m_member; will get the value.
int* xyz = &(instance->m_member); will give a pointer to m_member.
&(instance->m_member); is the address of m_member in your instance of CA.
Regards,
Brian Dela
|
|
|
|
|
Yeah, thank you!
Once a time I uesed "&(instance.m_member)" as a reference to the member.
As a result it was wrong(instance is an object). Then I replaced it with "(int *)instance.m_member", compiling is ok.
Maybe something else had been wrong.
Thank you again!
|
|
|
|
|
Your welcome.
Regards,
Brian Dela
|
|
|
|
|
I'm using the CreateFontDirect and trying to set the Point size of the height of the font and then display it. I'm using a map mode of MM_LOMETRIC, but the size is not the same as word diplays it. It works fine if the map mode is MM_TEXT.
Thanks
|
|
|
|
|
I need to create a program that will keep a list of folders synchronized, on-demand, between a number (10+) of computers on the internet. At a function call, I need a computer to be able to connect to the other computers and find and download the latest version of a specific folder. It also needs to use as little bandwidth and CPU as possible, because the computers with be also running game servers (this progam will interface somewhat with the game server, also).
Now, how should I go about doing that? I have zero experience in any network programming, but with all the articles here, I don't think it would take me too long to learn. Currently, I'm considering having a small http server and a http file download client on each computer, since that seems the simplest.
Thanks!
|
|
|
|
|
One soluton is winsock. Design your own server/client for custom system file synchronization.
Kuphryn
|
|
|
|
|
|
What's wrong with this function i used to find text in an edit control? I don't understand, it should work:
//CFindReplaceDialog FindDlg pre-defined
if (FindDlg->FindNext())
{
CString data;
GetDlgItemText(IDD_EDIT, data);
int FindIndex = data.Find(_T(FindDlg->GetFindString()), FindStart);//int FindStart global variable
if (FindIndex > -1)
{
FindStart = FindIndex + FindDlg->GetFindString().GetLength();
CEdit *edit = (CEdit *) GetDlgItem(IDD_EDIT);
MessageBox("testing...");
edit->SetSel(FindIndex, FindStart, FALSE);
}
else
{
MessageBox("The text you entered was not found.", "Text not found", MB_ICONINFORMATION);
}
}
What could be wrong with this code?
-- Steve
|
|
|
|
|
Make sure that FindStart has a valid value in it (set it to 0 or -1 and see if that helps).
The line
int FindIndex = data.Find(_T(FindDlg->GetFindString()), FindStart);
doesn't need the _T() (_T() is only used for string literals), but it won't make a difference unless you're compiling for unicode:
int FindIndex = data.Find(FindDlg->GetFindString(), FindStart);
Step through the code one line at a time and see what all your variables are after each statement. The code logic looks fine, so it should work.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|