SW 개발

winCE > 디바이스 > ActiveSync Disable / Enable 시키기

. . . 2009. 1. 15. 14:21
반응형
  • 마크다운변환 : 20190905

  • 기타사항 : EVC, winCE5 테스트완료. 오류사항이나 틀린점은 댓글로 달아주세여
  • 밑에도 나와있지만.. 해당 함수는 usb관련 기능에서 massStorage 기능과 activeSync 기능을 스위칭 할수있는것 같다. 일단 PDA특성상 massStorage 기능은 확인못했지만 activeSync기능은 disable / enable 을 테스트 완료했다.

...

You can certainly use the IOCTL_UFN_CHANGE_CURRENT_CLIENT to dynamically swap between a mass-storage profile and a serial (Activesync) one, so I think therefore it should also be possible to do the same to effectively enable/disable Activesync (by picking a different client):

http://msdn.microsoft.com/en-us/library/ms895475.aspx

USB Function Controller MDD IOCTLs

Platform Builder for Microsoft Windows CE 5.0
USB Function Controller MDD IOCTLs
Send Feedback
The following table shows the USB function controller driver IOCTLs.

IOCTL Description
IOCTL_UFN_ENUMERATE_AVAILABLE_CLIENTS_SETUP This IOCTL resets the internal client enumeration state and is called before enumeration. It takes no arguments.
IOCTL_UFN_ENUMERATE_AVAILABLE_CLIENTS This IOCTL passes the UFN_CLIENT_INFO structure as an out parameter. It receives a name and description of a client and keeps calling until it fails with ERROR_*.
IOCTL_UFN_GET_CURRENT_CLIENT This IOCTL passes the UFN_CLIENT_INFO structure as an out parameter. It receives a name and description of the current client. If it receives no current client, returns a null string for the name.
IOCTL_UFN_CHANGE_CURRENT_CLIENT This IOCTL passes the UFN_CLIENT_INFO structure as in parameter with the name of the current client. It unloads the current client and loads the specified client.
IOCTL_UFN_GET_DEFAULT_CLIENT This IOCTL gets information about the default client.
IOCTL_UFN_CHANGE_DEFAULT_CLIENT This IOCTL changes the default client.

예제코드1

HANDLE hUSBFn; 
UFN_CLIENT_INFO info; 
DWORD dwBytes; 

// Open the USB function driver 
hUSBFn = CreateFile(USB_FUN_DEV, DEVACCESS_BUSNAMESPACE, 0, NULL, 
                              OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); 

if(enableActiveSync) 
{ 
    // enable activesync 
    swprintf(info.szName, _T("Serial_Class")); 
    DeviceIoControl(hUSBFn, IOCTL_UFN_CHANGE_CURRENT_CLIENT, 
                            info.szName, sizeof(info.szName), NULL, 0, &dwBytes, NULL)) 
} 
else 
{ 
    // enable mass-storage, disable actviesync 
    swprintf(info.szName, _T("Mass_Storage_Class")); 
    DeviceIoControl(hUSBFn, IOCTL_UFN_CHANGE_CURRENT_CLIENT, 
                           info.szName, sizeof(info.szName), NULL, 0, &dwBytes, NULL); 
}

예제코드2

#include "winioctl.h" 
#include "usbfnioctl.h" 
#include "devload.h" 

#define USB_FUN_DEV L"UFN1:" 

void TogleActiveSync(bool bStatus) 
{ 
        HANDLE hUSBFn; 
        UFN_CLIENT_INFO info; 
        DWORD dwBytes;  

        // Open the USB function driver 
        hUSBFn = CreateFile(USB_FUN_DEV, DEVACCESS_BUSNAMESPACE, 0, NULL, 
                                      OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);  

        if(Status) 
        { 
                // enable activesync 
                swprintf(info.szName, _T("Serial_Class")); 
                DeviceIoControl(hUSBFn, IOCTL_UFN_CHANGE_CURRENT_CLIENT, info.szName, 
                                       sizeof(info.szName), NULL, 0, &dwBytes, NULL); 
        } 
        else 
        { 
                // enable mass-storage, disable actviesync 
                swprintf(info.szName, _T("Mass_Storage_Class")); 
                DeviceIoControl(hUSBFn, IOCTL_UFN_CHANGE_CURRENT_CLIENT, info.szName, 
                                       sizeof(info.szName), NULL, 0, &dwBytes, NULL); 
        } 
} 
반응형