B
BSODMASTER
Guest
First create a sample VPN connection from the Internet Options - it need to have a pbk file in `%userprofile%\AppData\Roaming\Microsoft\Network\Connections\PBK`. Then consider this sample code:
#include <Windows.h>
#include <ras.h>
main()
{
BOOL noCare;
HRASCONN conn=NULL;
RASCONNSTATUS status={.dwSize=sizeof status};
RASDIALPARAMS params={.dwSize=sizeof params,.szEntryName="VPN Connection"};
RasGetEntryDialParamsA(NULL,¶ms,&noCare);
while(true)
if(RasGetConnectStatusA(conn,&status)!=ERROR_INVALID_HANDLE)
do
RasHangUpA(conn),Sleep(0);
while(RasGetConnectStatusA(conn,&status)!=ERROR_INVALID_HANDLE);
else RasDialA(NULL,NULL,¶ms,0,NULL,&conn);
}
First time the call is always successful if you have configured your VPN right, however the second call and any following always fails with `ERROR_NO_CONNECTION`.
Any ideas why?
Continue reading...
#include <Windows.h>
#include <ras.h>
main()
{
BOOL noCare;
HRASCONN conn=NULL;
RASCONNSTATUS status={.dwSize=sizeof status};
RASDIALPARAMS params={.dwSize=sizeof params,.szEntryName="VPN Connection"};
RasGetEntryDialParamsA(NULL,¶ms,&noCare);
while(true)
if(RasGetConnectStatusA(conn,&status)!=ERROR_INVALID_HANDLE)
do
RasHangUpA(conn),Sleep(0);
while(RasGetConnectStatusA(conn,&status)!=ERROR_INVALID_HANDLE);
else RasDialA(NULL,NULL,¶ms,0,NULL,&conn);
}
First time the call is always successful if you have configured your VPN right, however the second call and any following always fails with `ERROR_NO_CONNECTION`.
Any ideas why?
Continue reading...