|
Hi,
In my program, I use asynchronies dial up connection with rasapi32 api.
From RasDialFunc, after RASCS_AuthNotify, I can’t get any other message.
Anybody knows why this happens?
Here is my RasDialFunc code.
VOID WINAPI RasDialFunc(UINT unMsg, RASCONNSTATE rasconnstate, DWORD dwError)
{
if ( dwError )
{
char szBuf[256];
if ( RasGetErrorString( dwError, (LPSTR)szBuf, 256 ) != 0 )
{
wsprintf( (LPSTR)szBuf, "Undefined RAS Dial Error (%ld).", dwError );
RasHangUp( g_hRasConn );
MessageBox(NULL, (LPSTR)szBuf, "Agni Dialer", MB_OK | MB_ICONSTOP );
}
return;
}
g_nLastRASConnState = rasconnstate;
LPCTSTR lpszMsg;
switch ( rasconnstate )
{
case RASCS_OpenPort : lpszMsg = "Openning Port"; break;
case RASCS_PortOpened : lpszMsg = "Port Opened"; break;
case RASCS_ConnectDevice : lpszMsg = "Connecting Device"; break;
case RASCS_DeviceConnected : lpszMsg = "Device Connected"; break;
case RASCS_AllDevicesConnected : lpszMsg = "All Devices Connected"; break;
case RASCS_Authenticate : lpszMsg = "Starting Authentication"; break;
case RASCS_AuthNotify : lpszMsg = "Authentication Notify"; break;
case RASCS_AuthRetry : lpszMsg = "Authentication Retry"; break;
case RASCS_AuthCallback : lpszMsg = "Callback Requested"; break;
case RASCS_AuthChangePassword : lpszMsg = "Change Password Requested"; break;
case RASCS_AuthProject : lpszMsg = "Projection Phase Started"; break;
case RASCS_AuthLinkSpeed : lpszMsg = "Link Speed Calculation"; break;
case RASCS_AuthAck : lpszMsg = "Authentication Acknowledged"; break;
case RASCS_ReAuthenticate : lpszMsg = "Reauthenticatation Started"; break;
case RASCS_Authenticated : lpszMsg = "Authenticated"; break;
case RASCS_PrepareForCallback : lpszMsg = "Preparation For Callback"; break;
case RASCS_WaitForModemReset : lpszMsg = "Waiting For Modem Reset"; break;
case RASCS_WaitForCallback : lpszMsg = "Waiting For Callback"; break;
case RASCS_Interactive : lpszMsg = "Interactive"; break;
case RASCS_RetryAuthentication : lpszMsg = "Retry Authentication"; break;
case RASCS_CallbackSetByCaller : lpszMsg = "Callback Set By Caller"; break;
case RASCS_PasswordExpired : lpszMsg = "Password Expired"; break;
case RASCS_Disconnected : lpszMsg = "Disconnected"; break;
case RASCS_Connected : lpszMsg = "Connected"; break;
}
g_csStatusMsg = lpszMsg;
}
|
|
|
|
|
MUuu..
Kuniva
--------------------------------------------
|
|
|
|
|
I've been reading Code Project for quite some time now, and this is the first question I've posted. I'm hoping the collective brain power here can help me track down a problem I'm having.
I have an application (written by me) that seems to be causing the windows clock (but not the RTC) to drift forward in time severely (say 24 seconds over 5 minutes) The application has a number of threads (maybe around 10) and services many TCP connections where the input/response packets are relatively small (90bytes to 1500 bytes)
I am at a loss to think what would make an application cause the windows clock to GAIN time. The processor utilization stays fairly low (below 30%) and it does not consume other resources at an unexpected rate. I was thinking maybe Windows is missing the time update interrupt and over compensating, but I don't believe this is true...
The truly odd thing is that I have a couple of other apps that do very similar tasks which share all the underlying code that this app does, which do NOT cause this problem.
Can anyone think of what to look for, or what to try to narrow the problem down?
Thanks,
Gavin Stark
|
|
|
|
|
I know this is going to sound off the wall, but are you using any sort of memory mapped files in this program? I've heard of cases where improper writing to mem-mapped strange problems. It would be a starting point...
It's good to see kids turning their minds to wholesum activities such as programming, instead of wasting their lives in the hedonistic disciplines of Sex, Drugs, & Rock & Roll... or Sex with Drugs, or Sex with Rocks while Rolling in Drugs, or whatever new-fangled perversions you little monsters have thought up now...
[Shog9 on Kid Programmers]
|
|
|
|
|
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!
|
|
|
|