안녕하세요. 초보윈폼 개발자입니다. 
SD리더기가 컴퓨터에 꽂혀있는 상태에서 SD카드를 꽂으면 이벤트가 반응하도록 하고 싶은데 쉽지않아 도움을 요청드립니다.
아래와 같이 시도를 하였고 
[용어설명 SD리더기 : SD카드, CF카드, micro SD카드 등을 꽂을 수 있는 리더기입니다. USB타입으로 컴퓨터와 연결해놓은 상태입니다.]
1. 시도한 방법
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);
            switch (m.Msg)
            {
                case WM_DEVICECHANGE:
                    switch ((int)m.WParam)
                    {
                        case DBT_DEVICEARRIVAL:
위와같이 하면 USB 슬롯에 꽂을때는 이벤트가 반응하지만 SD리더기가 꽂혀있는 상태에서 SD카드를 꽂으면 작동이 되지 않습니다. 
2. 시도한 방법
        public void WMIReceiveEvent()
        {
            WqlEventQuery q;
            ManagementScope scope = new ManagementScope("root\\CIMV2");
            scope.Options.EnablePrivileges = true;
            try
            {
                q = new WqlEventQuery();
                q.EventClassName = "__InstanceOperationEvent";
                q.WithinInterval = new TimeSpan(0, 0, 3);
                q.Condition = "TargetInstance ISA 'Win32_DiskDrive'";
                m_InsertManagementEventWatcher = new ManagementEventWatcher(scope, q);
                m_InsertManagementEventWatcher.EventArrived += StorageInserted;
                m_InsertManagementEventWatcher.Start();
            }
위와같이 하면 SD카드를 꽂을때와 뺄때 반응하지만 다른 메모리부분 작동시(예 dispose()) 비정상적으로 작동되어 일단 보류인 상태입니다.
3. 시도한 방법
 foreach (DriveInfo driveInfo in DriveInfo.GetDrives())
         {
            if (driveInfo.IsReady)
            {
                   if (driveInfo.DriveType == DriveType.Removable)
                   {
위와같이 하면 SD카드를 꽂을 때 이벤트가 실행되어야 하는데 이것을 백그라운드로 계속 돌릴 수도 없고...  정말 많이 찾아보고 했는데 방법이 보이지 않아 이렇게 남깁니다.
조금 도와주시면 정말 감사하겠습니다.
감사합니다.
좋은하루 보내세요.
        
        
                    
                    
                    
                    
                    
    
                    
                    
                    
                    
                    
                
                    [최초 등록일: ]
                    [최종 수정일: 4/1/2019]