Creating RAS Entry

M

Marc S

I have code that creates a RAS entry that runs fine on PPC 2000, 2002
and 2003. I ran it on a WIndows Mobile 5.0 device and I received an
error while calling RasSetEntryProperties() but when I clicked OK the
dialup connection when through fine. The only other odd thing is that
the entry is not displayed on the Connections screen.

If you have any ideas or need some code samples or more information
please let me know.

Thanks,
Marc S
 
M

Marc S

Marc said:
I have code that creates a RAS entry that runs fine on PPC 2000, 2002
and 2003. I ran it on a WIndows Mobile 5.0 device and I received an
error while calling RasSetEntryProperties() but when I clicked OK the
dialup connection when through fine. The only other odd thing is that
the entry is not displayed on the Connections screen.

If you have any ideas or need some code samples or more information
please let me know.

Thanks,
Marc S

Another thing that I forgot to mention is that my call to
lineGetDevConfig() returns a positive value. This is confusing because
the documentation says that it will return 0 upon success and a
negative value if an error occured.
 
D

DJMatty

Hi Marc

One alternative would be to use the DMProcessConfigXML API to create
ras connections, this uses the config manager that allows devices to be
provisioned and we have used it for created our GPRS connections on app
install.

I know it doesn't actually solve the problem you are having, but it may
be a workaround :)

Matt
 
M

Marc S

DJMatty said:
Hi Marc

One alternative would be to use the DMProcessConfigXML API to create
ras connections, this uses the config manager that allows devices to be
provisioned and we have used it for created our GPRS connections on app
install.

I know it doesn't actually solve the problem you are having, but it may
be a workaround :)

Matt


The only problem is that I am building it with evc3 to keep backwards
compatibility with previous PocketPC versions. We are trying to have a
single DLL for all platforms.
 
D

DJMatty

Hmmm ok, well one way to do it would be to build a cab provisioning
file which would get installed and run in your ppc2003 and wm 5 cabs...
that would provision those devices with the ras entries and no need for
code, just an xml file in a cpf... then you could just check if they
are already there in your dll and not create them if they are...

I know it's not ideal, and sorry i can't help you with why the api
isn't working, but it's an alternative :)

Matt
 
M

Marc S

DJMatty said:
Hmmm ok, well one way to do it would be to build a cab provisioning
file which would get installed and run in your ppc2003 and wm 5 cabs...
that would provision those devices with the ras entries and no need for
code, just an xml file in a cpf... then you could just check if they
are already there in your dll and not create them if they are...

I know it's not ideal, and sorry i can't help you with why the api
isn't working, but it's an alternative :)

Matt

Yeah, my boss isn't havin' that..lol Too many devices in the field to
update. Thanks for the idea though. Under different circumstances it
would have been ideal.

I wonder if the RAS entry is that much different in Mobile 5 than other
devices that building with evc3 against the 2002 SDK just plain won't
work.
 
D

DJMatty

Have you tried building a test WM5 app that just makes the entry using
the same api's you use?

At least it'll tell you if you can do it in a WM5 specific app and that
it's something to do with your dll being built in evc3...

Matt
 
M

Marc S

DJMatty said:
Have you tried building a test WM5 app that just makes the entry using
the same api's you use?

At least it'll tell you if you can do it in a WM5 specific app and that
it's something to do with your dll being built in evc3...

Matt


I just did and I didn't get the error but there is still no entry under
the Connections screen. It does dial fine though, just like the
version built in evc3.
 
D

DJMatty

I wonder if this is to do with connection manager, I seem to remember
we had problems getting the entries to display originally, it's to do
with associating it with 'My Work Network' or 'The Internet' or 'My
Internet' or any of the other ones... they seemed to change the names
of the default ones on different devices too (or maybe it was between
WM2003 and WM2003SE)

I wonder if using the old ras entry creation api's you can't put that
association in, the entry is there, but not visible as they are all
filtered in the connections applet.

Matt
 
M

Marc S

The registry entry that is set to display the available connections is
in a different place. It is located in
"comm\\ConnMgr\\Providers\\{7C4B7A38-5FF7-4bc1-80F6-5DA7870BB1AA}\\Connections"
as opposed to
"SOFTWARE\\Microsoft\\ConnMgr\\Providers\\{7C4B7A38-5FF7-4bc1-80F6-5DA7870BB1AA}\\Connections"
where it is in Pocket PC 2002.
 
M

Marc S

Here is how you get code compiled in evc3 that creates a RAS entry to
work on Windows Mobile 5, thanks to Randy:


The problem is that the RASENTRY structure in WM5 has an extra
paramater now!!! Have a look at the following....

lpRasEntry
[in] Pointer to the RASENTRY structure that specifies the new
connection data to be associated with the phone-book entry indicated by
the lpszEntry parameter.
The caller must provide values for the following members in the
RASENTRY structure.


szLocalPhoneNumber
szDeviceName
szDeviceType
dwFramingProtocol
dwfOptions
dwType
Important: dwType is only valid if WINVER >= 0x500.
If values are not provided for these members, RasSetEntryProperties
fails with ERROR_INVALID_PARAMETER.



The old structure from the EVC3 header ended befre this new required
parameter!!! We need to make a bigger structure and define dwType =
RASET_Phone

Take a look at the new definition (WM5)........

typedef struct tagRASENTRY {
DWORD dwSize;
DWORD dwfOptions;
//
// Location/phone number.
//
DWORD dwCountryID;
DWORD dwCountryCode;
TCHAR szAreaCode[ RAS_MaxAreaCode + 1 ];
TCHAR szLocalPhoneNumber[ RAS_MaxPhoneNumber + 1 ];
DWORD dwAlternateOffset;
//
// PPP/Ip
//
RASIPADDR ipaddr;
RASIPADDR ipaddrDns;
RASIPADDR ipaddrDnsAlt;
RASIPADDR ipaddrWins;
RASIPADDR ipaddrWinsAlt;
//
// Framing
//
DWORD dwFrameSize;
DWORD dwfNetProtocols;
DWORD dwFramingProtocol;
//
// Scripting
//
TCHAR szScript[ MAX_PATH ];
//
// AutoDial
//
TCHAR szAutodialDll[ MAX_PATH ];
TCHAR szAutodialFunc[ MAX_PATH ];
//
// Device
//
TCHAR szDeviceType[ RAS_MaxDeviceType + 1 ];
TCHAR szDeviceName[ RAS_MaxDeviceName + 1 ];
//
// X.25
//
TCHAR szX25PadType[ RAS_MaxPadType + 1 ];
TCHAR szX25Address[ RAS_MaxX25Address + 1 ];
TCHAR szX25Facilities[ RAS_MaxFacilities + 1 ];
TCHAR szX25UserData[ RAS_MaxUserData + 1 ];
DWORD dwChannels;
//
// Reserved
//
DWORD dwReserved1;
DWORD dwReserved2;
#if (WINVER >= 0x401)
//
// Multilink and BAP
//
DWORD dwSubEntries;
DWORD dwDialMode;
DWORD dwDialExtraPercent;
DWORD dwDialExtraSampleSeconds;
DWORD dwHangUpExtraPercent;
DWORD dwHangUpExtraSampleSeconds;
//
// Idle time out
//
DWORD dwIdleDisconnectSeconds;
#endif
#if (WINVER >= 0x500)
DWORD dwType;
DWORD dwEncryptionType;
DWORD dwCustomAuthKey;
GUID guidId;

TCHAR szCustomDialDll[MAX_PATH];
DWORD dwVpnStrategy;
#endif
#if (WINVER >= 0x501)
DWORD dwfOptions2;
DWORD dwfOptions3;
TCHAR szDnsSuffix[RAS_MaxDnsSuffix];
DWORD dwTcpWindowSize;
TCHAR szPrerequisitePbk[MAX_PATH];
TCHAR szPrerequisiteEntry[RAS_MaxEntryName + 1];
DWORD dwRedialCount;
DWORD dwRedialPause;
#endif
} RASENTRY;



and compare that to the one you are using (evc3)........

typedef_struct_RASENTRY{
DWORD dwSize;
DWORD dwfOptions;
DWORD dwCountryID;
DWORD dwCountryCode;
TCHAR szAreaCode[ RAS_MaxAreaCode + 1 ];
TCHAR szLocalPhoneNumber[ RAS_MaxPhoneNumber + 1 ];
DWORD dwAlternatesOffset;
RASIPADDR ipaddr;
RASIPADDR ipaddrDns;
RASIPADDR ipaddrDnsAlt;
RASIPADDR ipaddrWins;
RASIPADDR ipaddrWinsAlt;
DWORD dwFrameSize;
DWORD dwfNetProtocols;
DWORD dwFramingProtocol;
TCHAR szScript[ MAX_PATH ];
TCHAR szAutoDialDll[ MAX_PATH ];
TCHAR szAutoDialFunc[ MAX_PATH ];
TCHAR szDeviceType[ RAS_MaxDeviceType + 1 ];
TCHAR szDeviceName[ RAS_MaxDeviceName + 1 ];
TCHAR szX25PadType[ RAS_MaxPadType + 1 ];
TCHAR szX25Address[ RAS_MaxX25Address + 1 ];
TCHAR szX25Facilities[ RAS_MaxFacilities + 1 ];
TCHAR szX25UserData[ RAS_MaxUserData + 1 ];
DWORD dwChannels;
DWORD dwReserved1;
DWORD dwReserved2;
}RASENTRY;


See..... it ends at dwReserved2.

Since dwType is a required parameter now and you are not supplying it I
would bet you a round of drinks that this is the problem. Try manually
creating your own structure definition as follows and using that in
place of the RASENTRY structure you were using before. Something like:


struct WM5_RASENTRY
{
DWORD dwSize;
DWORD dwfOptions;
DWORD dwCountryID;
DWORD dwCountryCode;
TCHAR szAreaCode[ RAS_MaxAreaCode + 1 ];
TCHAR szLocalPhoneNumber[ RAS_MaxPhoneNumber + 1 ];
DWORD dwAlternateOffset;
RASIPADDR ipaddr;
RASIPADDR ipaddrDns;
RASIPADDR ipaddrDnsAlt;
RASIPADDR ipaddrWins;
RASIPADDR ipaddrWinsAlt;
DWORD dwFrameSize;
DWORD dwfNetProtocols;
DWORD dwFramingProtocol;
TCHAR szScript[ MAX_PATH ];
TCHAR szAutodialDll[ MAX_PATH ];
TCHAR szAutodialFunc[ MAX_PATH ];
TCHAR szDeviceType[ RAS_MaxDeviceType + 1 ];
TCHAR szDeviceName[ RAS_MaxDeviceName + 1 ];
TCHAR szX25PadType[ RAS_MaxPadType + 1 ];
TCHAR szX25Address[ RAS_MaxX25Address + 1 ];
TCHAR szX25Facilities[ RAS_MaxFacilities + 1 ];
TCHAR szX25UserData[ RAS_MaxUserData + 1 ];
DWORD dwChannels;
DWORD dwReserved1;
DWORD dwReserved2;
DWORD dwSubEntries;
DWORD dwDialMode;
DWORD dwDialExtraPercent;
DWORD dwDialExtraSampleSeconds;
DWORD dwHangUpExtraPercent;
DWORD dwHangUpExtraSampleSeconds;
DWORD dwIdleDisconnectSeconds;
DWORD dwType;
DWORD dwEncryptionType;
DWORD dwCustomAuthKey;
GUID guidId;
TCHAR szCustomDialDll[MAX_PATH];
DWORD dwVpnStrategy;
};

memset everything to NULL, set it up using your existing code, and set
the dwType to RASET_Phone !!!
I looked it up and RASET_Phone is defined as:

// The entry type used to determine which UI properties
// are to be presented to user. This generally corresponds
// to a Connections "add" wizard selection.
//
#define RASET_Phone 1 // Phone lines: modem, ISDN, X.25, etc
#define RASET_Vpn 2 // Virtual private network
#define RASET_Direct 3 // Direct connect: serial, parallel
#define RASET_Internet 4 // BaseCamp internet
#if (WINVER >= 0x501)
#define RASET_Broadband 5 // Broadband
#endif


I would juset define it as 1 manually.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top