Solved

ras.h question

Posted on 2004-08-18
3
315 Views
Last Modified: 2013-11-17
i am making a dialer i want it to run on all windows platforms 98, 2000, XP
this is part of code

#pragma warn -dup
#define WINVER 0x400
#include <ras.h>

    char newentryname[100];
    DWORD entrysize, configsize, error;
    BYTE configbuffer[512];
    bool password;
    char buffer[512];

    configsize = sizeof(configbuffer);
    RASENTRY entry;

    String name = (String)entryname;
    strcpy(newentryname, name.c_str());

    memset(&entry, 0, sizeof(RASENTRY));
    entrysize = sizeof(RASENTRY);
    entry.dwSize = sizeof(RASENTRY);

        int version1=GetOSVersion();
        if (version1==1)
        {
                entry.dwfOptions=8984;
        }
        else if(version1==2)
        {
                //entry.dwfOptions=1024197400;
                entry.dwfOptions=RASEO_SwCompression|RASEO_IpHeaderCompression|RASEO_RemoteDefaultGateway|RASEO_ModemLights|0x01000000|0x04000000;
                  //entry.dwType=RASET_Phone;
        }
        else if(version1==3)
        {
                entry.dwfOptions=RASEO_SwCompression|RASEO_IpHeaderCompression|RASEO_RemoteDefaultGateway|RASEO_ModemLights;
        }
        else {ShowMessage("Can not detect OS Version");}
       
                String strDeviceType=GetDeviceType();
                String strDeviceName=GetDeviceName();
                   strcpy(entry.szDeviceType, strDeviceType.c_str());
            strcpy(entry.szDeviceName, strDeviceName.c_str());
              strcpy(entry.szLocalPhoneNumber, "07777007");
              strcpy(entry.szDeviceType,RASDT_Modem);
              entry.dwFramingProtocol=RASFP_Ppp;
                entry.dwfNetProtocols=RASNP_Ip;

        error = RasSetEntryProperties (NULL, newentryname,&entry, entrysize, configbuffer, configsize);
    if(error)
    {
        RasGetErrorString(error, buffer, sizeof(buffer));
        ShowMessage(buffer);
        return false;
    }
    return true;

but this only work on win 98 when i try to put some other properties for win 2000 the compiler stops with error message it does not understand these properties unless i change
#define WINVER 0x400
with
#define WINVER 0x500

but i want one program to run on all platforms
and when i ignore this line and dont pass it an error message is generated saying an incorrect structure size , ithink it is the RASENTRY structure
what is the solution for that problem
thx
0
Comment
Question by:tamour2004
3 Comments
 
LVL 9

Accepted Solution

by:
Cayce earned 250 total points
ID: 11834156
You need to work with WINVER 0x400 for it to work on all versions. Or you can create a different DLL for each windows version and compile it with different WINVER values and options.

Something like this (pseudo code):

  ver = GetWindowsVersion();
  switch(ver)
  {
  case Win95: hLib = LoadLibrary("dialer95.dll"); break;
  case Win98: hLib = LoadLibrary("dialer98.dll"); break;
  case Win2k: hLib = LoadLibrary("dialer2k.dll"); break;
  case WinXP: hLib = LoadLibrary("dialerxp.dll"); break;
  }
  // Now load the address procs from hLib and call the procedures
  // each dll would be compiled with different options (WINVER for instance)
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Visual Studio 2013 5 75
Adding ribbon in custom Tab in word 2007 using VBA editor 10 70
Eclipse XML hightlightning 5 55
Should CArray be used for a list of pointers in C++? 19 102
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question