'개발'에 해당되는 글 46건

  1. 2009.05.07 Phonebook Operation
  2. 2009.04.21 HSDPA 연결은 RAS?? Connection Manager??
  3. 2009.04.20 Starting a RAS Connection
  4. 2009.04.20 Getting Started with PPP, RAS, and serial modem
  5. 2009.04.20 Windows Mobile용 삼성전자 SDK
2009. 5. 7. 17:33

Phonebook Operation


Phone-Book Operation

Entries in the Remote Access Service phone book contain the data necessary to establish a RAS connection. Unlike Windows-based desktop operating systems, which keep phone-book entries in a file, Windows CE stores these entries in the registry.

To make a connection without using a phone-book entry, RasDial can specify an empty string for the szEntryName member of the RASDIALPARAMS structure. The szPhoneNumber member must contain the phone number to dial.

RAS phone-book data includes:

·                 The phone number to dial, including country/region code and area code.

·                 The IP addresses to use while the connection is active.

·                 The network protocols.

·                 The type of device used to make the connection.

Windows CE supports a limited set of Window-based desktop functions for working with phone-book entries. The application can use the RasGetEntryProperties or RasSetEntryProperties function to create or edit a phone-book entry. The application can use the RasGetEntryDialParams and RasSetEntryDialParams functions to set or retrieve the connection parameters for a phone-book entry. The RasEnumEntries function lists all the phone-book entry names using the RASENTRY structure.

Data for the RAS phone book is stored in the registry under the HKEY_CURRENT_USER\Comm\RasBook key. See RAS Registry Settings for details.

Creating or Changing a Phone-Book Entry

You can use use the RasSetEntryProperties function to create or change phone-book entries.

To create or change registry phone-book entries

1.               Call RasValidateEntryName to be sure that the name does not exist.

2.               If you are editing an existing entry, call RasGetEntryProperties to retrieve the existing configuration.

3.               Call RasSetEntryProperties to set the new configuration. The following glist shows how the parameters should be set:

·                         The lpszName parameter should point to the null-terminated string containing the entry name in the lpszEntry parameter. If the existing name matches an existing entry, RasSetEntryProperties modifies the entry properties. If the entry does not exist, the function creates a new entry.

·                         The lpszEntry parameter should point to a RASENTRY structure, which should be filled with data for the connection, including the telephone number, device type, and name.

·                         The lpbDeviceInfo and dwDeviceInfoSize parameters can be used to set Telephony API (TAPI) device configuration data.

Creating a Phone-Book Entry Example

The following code example shows how to create a phone-book entry.

int CreateRasEntry (LPTSTR lpszName)
{
  DWORD dwSize,
        dwError;
  TCHAR szError[100];
  RASENTRY RasEntry;
  RASDIALPARAMS  RasDialParams;
 
  // Validate the format of a connection entry name.
  if (dwError = RasValidateEntryName (NULL, lpszName))
  {
    wsprintf (szError, TEXT("Unable to validate entry name.")
              TEXT(" Error %ld"), dwError);  
 
    return FALSE;
  }
 
  // Initialize the RASENTRY structure.
  memset (&RasEntry, 0, sizeof (RASENTRY));
 
  dwSize = sizeof (RASENTRY);
  RasEntry.dwSize = dwSize;
 
  // Retrieve the entry properties.
  if (dwError = RasGetEntryProperties (NULL, TEXT(""),      
                      (LPBYTE)&RasEntry, &dwSize, NULL, NULL))  
  {
    wsprintf (szError, TEXT("Unable to read default entry properties.")
              TEXT(" Error %ld"), dwError);
    return FALSE;
  }
 
  // Insert code here to fill the RASENTRY structure.
  // ...
  
  // Create a new phone-book entry.
  if (dwError = RasSetEntryProperties (NULL, lpszName, 
                      (LPBYTE)&RasEntry, sizeof (RASENTRY), NULL, 0))
  {
    wsprintf (szError, TEXT("Unable to create the phonebook entry.")
              TEXT(" Error %ld"), dwError);
    return FALSE;
  }
 
  // Initialize the RASDIALPARAMS structure.
  memset (&RasDialParams, 0, sizeof (RASDIALPARAMS));
  RasDialParams.dwSize = sizeof (RASDIALPARAMS);
  _tcscpy (RasDialParams.szEntryName, lpszName);
  
  // Insert code here to fill up the RASDIALPARAMS structure.
  // ...
 
  // Change the connection data.
  if (dwError = RasSetEntryDialParams (NULL, &RasDialParams, FALSE))
  {
    wsprintf (szError, TEXT("Unable to set the connection information.")
              TEXT(" Error %ld"), dwError);
    return FALSE;
  }
 
  return TRUE;
}

Changing an Existing Phone-Book Entry

The RasRenameEntry function renames a phone-book entry in the registry, while the RasDeleteEntry function deletes an entry. To verify if the string is in the correct format, the application can use the RasValidateEntryName function.

To change a registry phone-book entry

1.               Call RasValidateEntryName to verify the new name.

2.               Call the RasRenameEntry function to change the name.

The return value is zero if successful, and a RAS error value is returned if it is not successful.

Changing a Phone-Book Entry Example

The following code example shows how to change an existing phone-book entry.

BOOL RenameRasEntry (LPTSTR lpszOldName, LPTSTR lpszNewName)
 
{
  DWORD dwError;            // Return code from functions 
  TCHAR szError[120];       // Buffer for error message 
 
  if (dwError = RasValidateEntryName (NULL, lpszNewName))
  {
    wsprintf (szError, TEXT("Entry name validation failed: %ld"), 
              dwError);
    return FALSE;
  }
 
  if (dwError = RasRenameEntry (NULL, lpszOldName, lpszNewName))
  {
    wsprintf (szError, TEXT("Unable to rename entry: %ld"), dwError);
    return FALSE;
  }
 
  return TRUE;
}

Enumerating Phone-Book Entries

The RasEnumEntries function is used to enumerate a list of phone-book entries. Using this list, a user can select a RAS connection.

To enumerate phone-book entries

1.               Allocate an array for the RASENTRYNAME structure.

2.               Call RasEnumEntries to list the names in the phone book.

3.               Display the list for a user.

Enumerating Phone-Book Entry Example

The following code example shows how to dial and connect to a phone-book entry in the registry.

BOOL GetPhonebookEntries (HWND hDlgWnd)
{
  int index;
  DWORD dwSize, 
        dwEntries;
  HWND hWndListBox;
 
  // Allocate an array of RASENTRYNAME structures. Assume 
  // no more than 20 entries to be configured on the 
  // Windows CE-based device.
 
  if (!(lpRasEntryName = new RASENTRYNAME [20]))
  {
    MessageBox (hDlgWnd, TEXT("Not enough memory"), szTitle, MB_OK);
    return FALSE;
  }
 
  // Initialize the dwSize member of the first RASENTRYNAME structure
  // in the array to the size of the structure to identify 
  // the version of the structure being passed.
  lpRasEntryName[0].dwSize = sizeof (RASENTRYNAME);
 
  // Size of the array, in bytes
  dwSize = sizeof (RASENTRYNAME) * 20;
 
  // List all entry names in a remote access Phone book.
  if ((RasEnumEntries (
          NULL,               // Reserved, must be NULL
          NULL,               // Phone book is stored in the Windows CE
                              // registry.
          lpRasEntryName,     // Pointer to structure to receive entries
          &dwSize,            // Size of lpRasEntryName, in bytes
          &dwEntries)) != 0)  // Number of entries placed in array
  {
    MessageBox (hDlgWnd, TEXT("Could not obtain RAS entries"), szTitle,
                MB_OK);
    return FALSE;
  }
 
  // Get the HWND of the list box control.
  hWndListBox = GetDlgItem (hDlgWnd, IDC_RASNAMES);
 
  // Remove all items from a list box.
  SendMessage (hWndListBox, LB_RESETCONTENT, 0, 0);
 
  // Add the names of each RAS connection to the list box.
  for (index = 0; index < (int)dwEntries; ++index)
  {
    SendMessage (hWndListBox, LB_INSERTSTRING, index, 
                 (LPARAM)lpRasEntryName[index].szEntryName);
  }
 
  return TRUE;
}

Copying a Phone-Book Entry

An application can use the RasGetEntryProperties or RasSetEntryProperties function to copy the configuration data to another entry. The lpszEntryName parameter can be used to change the entry.

To copy a phone-book entry to the dialing list

1.               Call RasGetEntryProperties to get current phone-book properties.

2.               Call RasSetEntryProperties to set new phone-book properties.

3.               Call RasGetEntryDialParams to retrieve current user data.

4.               Call RasSetEntryDialParams to set user password data.

The return value is TRUE if successful and FALSE if not.

Deleting a Phone-Book Entry

To delete a phone-book entry the application can use the RasDeleteEntry function.

To delete a phone-book entry from the dialing list

·                 Call RasDeleteEntry using the lpszName parameter to supply the entry to be deleted.

The return value is TRUE if successful and FALSE if not.

Deleting a Phone-Book Entry Example

The following code example shows how to delete a RAS phone-book entry from the dialing list.

BOOL DeleteRasEntry (LPTSTR lpszName)
{
  DWORD dwError;            // Return code from RasDeleteEntry
  TCHAR szError[100];       // Buffer for error message 
 
  if (dwError = RasDeleteEntry (NULL, lpszName))
  {
    wsprintf (szError, TEXT("Unable to delete entry: %ld"), dwError);
    return FALSE;
  }
 
  return TRUE;
}

[출처] PhoneBook Entry|작성자 새벽

2009. 4. 21. 13:09

HSDPA 연결은 RAS?? Connection Manager??


2G망 (CDMA)은 한 회선으로 음성 및 네트워크가 이루어진단다.

3G망 (WCDMA)은 음성과 네트워크가 다른 회선으로 이루어진단다.

그런데 RAS는 음성 회선을 이용하게 되므로 CDMA에서 하는거랑 차이가 없단다.

WCDMA에서 말하는 HSDPA는 고속으로 데이터를 처리하기 위한 통신 방식으로 음성과 분리되어 있단다.

따라서 이 놈을 이용할 때는 CM (Connection Manager)를 이용해야 한단다.

MSDN과 커뮤니티를 통해 좀 더 찾아봐야 할듯.. ㅎ


MSDN Library
- http://msdn.microsoft.com/en-us/library/ms879581.aspx



<13:40 추가>

CONNMGR_CONNECTIONINFO pConnInfo; //Connect Manager 구조체
ZeroMemory(&pConnInfo, sizeof(CONNMGR_CONNECTIONINFO));//구조체 초기화
pConnInfo.cbSize = sizeof(CONNMGR_CONNECTIONINFO); //구조체 사이즈
pConnInfo.dwParams = CONNMGR_PARAM_GUIDDESTNET;
pConnInfo.dwPriority = CONNMGR_PRIORITY_USERINTERACTIVE;

pConnInfo.dwFlags = 0;

pConnInfo.bExclusive = false;
pConnInfo.bDisabled = false;
pConnInfo.guidDestNet = IID_DestNetInternet;

pConnInfo.hWnd = NULL;

pConnInfo.lParam = (LPARAM)0;
HANDLE hConnection = NULL;

DWORD status = CONNMGR_STATUS_CONNECTED;
HRESULT hr = ConnMgrEstablishConnectionSync(&pConnInfo, &hConnection,15000, &status);
if (hr != S_OK)
{
     AfxMessageBox(_T("전화접속에 실패 하였습니다."));
}



<13:50 추가>
http://www.codeproject.com/KB/mobile/ConnectionManager.aspx?display=Print

2009. 4. 20. 14:39

Starting a RAS Connection

 

The RasDial function indicates a successful connection in two ways. If RasDial make a successful connection:

  • It returns a zero. A nonzero value indicates failure.
  • The function stores a handle to the RAS connection in the variable pointed to by the function parameter pRasConn.

The RasDial function must specify data so that RAS can establish the connection from a Windows CE–based device to a remote access server. The client uses the RasDial function parameters to specify a phone-book entry. The lpszPhonebookPath parameter must be NULL. The lpRasDialParams parameter points to a RASDIALPARAMS structure that specifies the phone-book entry to use. To connect, the RasDial function must specify the data necessary to establish a connection. Typically, the RasDial call provides the connection data by specifying a phone-book entry using the RASDIALPARAMS structure to provide data such as a phone number, user name, domain, and password.

Instead of having the user supply credential information before RasDial is called, you can also set the RASEO_PreviewUserPw option bit in the RASENTRY structure. Setting this option bit causes a username and password dialog box to be displayed to the user before dialing occurs.

The connection data includes callback and user authentication data. To make a connection, the RasDial function can specify an empty string for the szEntryName member of the RASDIALPARAMS structure. This will result in the first available modem being used. The szPhoneNumber member must contain the phone number to dial.

To use RasDial to establish a connection

  1. Set the dialExtensions parameter to NULL.
  2. Set the lpszPhonebook parameter to NULL. Phone-book entries are stored in the registry rather than in a phone-book file.
  3. Set the dwNotiferType parameter to 0xFFFFFFFF, specifying the lpvNotifier parameter as a handle to the window receiving progress notification messages. If the application requires messages from RAS, the messages must be sent to a window handle. There is no support for callback functions.
  4. If you have not set the RASEO_PreviewUserPw option bit in the RASENTRY structure, which presents the user with a username and password dialog box before dialing, set the szEntryName, szUserName, szPassword, and szDomain members of the RASDIALPARAM structure. Pass a pointer to this structure into lpRasDialParam.

RAS Connection Example

The following code example shows how to establish a RAS connection.

BOOL MakeRasDial (HWND hDlgWnd)
{
  BOOL bPassword;
  TCHAR szBuffer[100];

  if (bUseCurrent)
  {
    // Get the last configuration parameters used for this connection. 
    // If the password was saved, then the logon dialog box will not be
    // displayed.
    if (RasGetEntryDialParams (NULL, &RasDialParams, &bPassword) != 0)
    {
      MessageBox (hDlgWnd, 
                  TEXT("Could not get parameter details"), 
                  szTitle, 
                  MB_OK);
      return FALSE;
    }
  }
  else
  {
    // Display the Authentication dialog box.
    DialogBox (hInst, MAKEINTRESOURCE(IDD_AUTHDLG), hDlgWnd, 
               AuthDlgProc);

    // Set hRasConn to NULL before attempting to connect.
    hRasConn = NULL;

    // Initialize the structure.
    memset (&RasDialParams, 0, sizeof (RASDIALPARAMS));

    // Configure the RASDIALPARAMS structure. 
    RasDialParams.dwSize = sizeof (RASDIALPARAMS);
    RasDialParams.szPhoneNumber[0] = TEXT('\0');
    RasDialParams.szCallbackNumber[0] = TEXT('\0');
    wcscpy (RasDialParams.szEntryName, szRasEntryName);
    wcscpy (RasDialParams.szUserName, szUserName); //This is optional    wcscpy (RasDialParams.szPassword, szPassword); //This is optional
    wcscpy (RasDialParams.szDomain, szDomain); //This is optional
  }

  // Try to establish RAS connection.
  if (RasDial (NULL,            // Extension not supported
               NULL,            // Phone book is in registry
               &RasDialParams,  // RAS configuration for connection
               0xFFFFFFFF,      // Notifier type is a window handle
               hDlgWnd,         // Window receives notification message
               &hRasConn) != 0) // Connection handle
  {
    MessageBox (hDlgWnd, 
                TEXT("Could not connect using RAS"), 
                szTitle, 
                MB_OK);
    return FALSE;
  }

  wsprintf (szBuffer, TEXT("Dialing %s..."), szRasEntryName);

  // Set the Dialing dialog box window name to szBuffer.
  SetWindowText (hDlgWnd, szBuffer);

  return TRUE;
}
2009. 4. 20. 13:44

Getting Started with PPP, RAS, and serial modem


MSDN forum을 뒤지던중.. 좋은 질문&답변 발견

내가 하고 싶던 질문이야..

Where can I find information on using PPP. RAS, and a serial modem to do FTP? I'm prototyping using Windows CE 5.0, but I think the target system will run Windows CE 6.0. Things I have not yet been able to figure out:

  • How to tell Windows CE to use a serial modem on a particular COM port
  • How to FTP a file after a successful RAS connection


PPP, RAS와 serial modem을 사용하여 FTP를 사용하는 방법? 
이라는 질문이구만..

이에 대한 답변은..


If you're a C/C++ developer then you don’t need to P/Invoke (which is a way to call into the OS for .Net developers).

Just use RAS API - which RasDial() is part of. There are method to create connection - RasSetEntryProperties(), then you can use RasDial() on it. It would dial out and establish PPP connection and you just get TCP/IP working on your device.

It is possible your CE device has no RAS API though - in which case you probably won't be able to use it.

Here's RAS API: http://msdn.microsoft.com/en-us/library/ms897066.aspx

For FTP you can use WinInet API: http://msdn.microsoft.com/en-us/library/aa451973.aspx

Again, it’s optional, might not be available on your device. You can fall back to sockets. There are no FTP sockets, just sockets.  Once you have socket opened to the server you can transmit and receive data through it as FTP protocol specifies. You can find description on the web, just search for “RFC FTP”.

Platform SDK is for desktop only, BTW, does not work for CE. You would need to obtain SDK for your CE device from device manufacturer.

Also you probably know that but just in case: you would need special compilers as well, desktop compilers won’t work in CE. You can use VS 2005 SE or above or VS 2008 Pro or above to develop for CE.

만약에 C/C++ 개발자는 P/Invoke를 신경쓰지 않아도 된단다. 그리고 RAS API만을 사용하면 된다고 한다. RasDial()이 있고. 연결을 성립하기 위한 RasSetEntryProperties()의 메서드를 가지고 있고 이어 RasDial()을 사용한다고 한다. 메서드는 연결을 위한 정보같은걸 가지고 있는건가? 그리고.. 연결.. 머 이런식인가보네.. ㅋ PPP 연결을 확립한 이후에 TCP/IP 를 디바이스에서 수행할수 있다고 하네

그리고.. RAS API에 대한 설명과.. 주요한건 FTP 서비스를 제공하는 API가 있다는 것이다. Internet Client Service에 보니까 HTTP와 FTP를 제공한다는군.

추가적인 기능으로 디바이스에서 사용할 수 있으며 소켓으로 fall back할 수 있다고 한다. FTP 소켓이 아닌 그냥 소켓. 한 번 소켓을 서버로 열면 데이터를 FTP 프로토콜 스펙으로 전송, 수신할 수 있다고 한다. 이러한 것은 RFP FTP에서 볼 수 있다고.

좋은 정보구만 ㅎ

원문 : http://social.msdn.microsoft.com/Forums/en-US/windowsmobiledev/thread/f9001457-cbfe-4fb9-a59e-454060c746dd/

2009. 4. 20. 08:59

Windows Mobile용 삼성전자 SDK


요즘 T옴니아로 인기를 끌고 있는 삼성전자가 드디어 개발자를 위해 Samsung Mobile Innovator 웹 사이트에서 드디어 Windows Mobile용 삼성전자 확장 SDK를 발표했네요!!

처음에는 북유럽을 위한 심비안 S60 으로 부터 시작하여 어제에 드디어 Windows Mobile용 삼성전자 SDK가 발표가 되었습니다. 이 삼성전자 Windows Mobile 용 확장 SDK는 멤버쉽 등록을 해야 하는데, 멤버쉽은 무료로 가입할 수 있습니다. 설치하고 나면 몇 가지 재미나는 내용들이 있는데 한번 살펴 보도록 하겠습니다.

image_3

우선 먼저 눈에 뛰는 것은 일반 초보 개발자들을 위해 Getting Started 으로 Hello, World 자습서가 나와 있네요. 비록 영어로 된 문서이지만 한 번 따라 해 보시면 될 것 같습니다. 위와 같이 따라 해 보기 위해서는 Visual Studio 2008 Professional Edition 이상 되는 버전과 무료로 공개되는 Windows Mobile 6 SDK가 필요합니다. 설치 순서는 “처음으로 T옴니아폰 응용프로그램을 개발하려면” 이라는 기사를 참고하시기 바랍니다.

삼성전자의 Windows Mobile 용 확장 SDK의 주요 특징으로는 자이로 센서라고 부르는 액셀러메이터(Accelerometer)와, LED 표시 그리고 햅틱 등을 사용할 수 있도록 개발자들에게 API를 제공합니다.

더욱이 옴니아는 다른 윈도우 폰과 같이 달리 480 * 800의 화면 크기를 가지고 있습니다. 그렇다 보니 다른 에뮬레이터에서 사용할 때 화면 크기가 달리 불편 했었습니다. 그래서 T옴니아 SW경진대회 때에도 옴니아와 비슷한 크기의 6.1.4 이미지를 권장했으나 이제부터 옴니아 전용 에뮬레이터를 사용하면 될 것 같습니다. 

Lab.dev 이라는 가상 장치 랩을 모바일 이노베이션 랩에 준비해서 옴니아 장치가 없어도 웹에서 접속해서 여러분의 애플리케이션을 설치하고 테스트 해 볼 수 있는 환경을 제공 해 줍니다. 또한 개발자 기술 지원 및 커뮤니티를 위해 Windows Mobile Discussion Board 를 마련해 놓고 있으며 누구든지 글을 올리거나 답변할 수 있습니다.

삼성전자 장치 에뮬레이터의 스킨은 옴니아 폰 뿐만 아니라 블랙잭II, Epix/Mirage, Robin, Saga, ACE 및 Omni 등이 더 포함되어 있습니다. 고객의 여러 가지 피드백을 위해 Knowlege Base 도 개발 되었으니 참조해 주시기 바랍니다.

삼성 모바일 이노베이터의 WiKi 서비스를 통한 디지털 마케팅을 위해 Samsung Device Database 를 서비스하며, Samsung Windows Mobile SDK 문서도 공개해 놓았습니다. 이로서 애플리케이션 개발자들은 삼성전자가 개발한 윈도우 모바일 기반 스마트폰 애플리케이션을 쉽고 빠르게 개발할 수 있도록 지원해 줍니다.