Right now, when the RasDial function is run synchronously, the program is unusable unless it is disconnected.

In contrast, when the RasDial function is run asynchronously, it immediately jumps to the callback function and doesn't dial up anymore. It returns success straight after the callback function is finished.

I am a bit confused about the use of the callback function parameter in the RasDial function. Here is the RasDial function:

Code:
DWORD RasDial(
  LPRASDIALEXTENSIONS lpRasDialExtensions,
  LPCTSTR lpszPhonebook,
  LPRASDIALPARAMS lpRasDialParams,
  DWORD dwNotifierType,
  LPVOID lpvNotifier,
  LPHRASCONN lphRasConn
);
Is it like I have to set dwNotifierType to 0 and put a self-defined function into the lpvNotifier parameter, and then the RasDial function will do the dial-up while executing the callback function? Is there anything I have missed? Or is there something I have done wrong?

By the way, I still don't understand the concept of RasDialFunc. What does the placeholder mean? What does that do? (Sorry, maybe this is a silly question. I am just a programming beginner).

Here is my code:
Code:
typedef LPVOID (*RASDIALFUNC)(UINT, RASCONNSTATE, DWORD);

LPVOID RasDialFunction(UINT unMsg, RASCONNSTATE rascs, DWORD dwError)
{
     /* No coding at the moment */
}

bool DialUp(void) 
{
    char szPhoneNumberToDial[RAS_MaxEntryName+1];
    char szUserName[UNLEN+1];
    char szPassword[PWLEN+1];
    
    printf("Please enter the telephone number: ");
    gets(szPhoneNumberToDial);

    // Fill RASDIALPARAMS structure
    RASDIALPARAMS rdParams;
    rdParams.dwSize = sizeof(RASDIALPARAMS);
    rdParams.szEntryName[0] = '\0';
    lstrcpy(rdParams.szPhoneNumber, szPhoneNumberToDial);
    rdParams.szCallbackNumber[0] = '\0';
    lstrcpy(rdParams.szUserName, szUserName);
    lstrcpy(rdParams.szPassword, szPassword);    
    rdParams.szDomain[0] = '\0';

    // Call RasDial Function
    HRASCONN hRasConn = NULL;
    RASDIALFUNC rdFunc;
    rdFunc = RasDialFunction;

    DWORD dwRet = RasDial(NULL, NULL, &rdParams, 0L, rdFunc(WM_RASDIALEVENT, RASCS_OpenPort, 0), &hRasConn);

    /* Further more codes...... */
}
I have been stucked for a few weeks already. So please HELP!
Thanks!

Last edited by shabbir; 31Jul2007 at 11:43.. Reason: Code block