Beispiel #1
0
        FindDBCallback(object sender, System.EventArgs e)
        {
            INVOKE_ENUMDB it    = this.m_thrdFindDB.itReason;
            string        strIn = m_thrdFindDB.strBuffer;

            switch (it)
            {
            case INVOKE_ENUMDB.ENUMDB_NEWVOLUME:
                this.lboxDatabases.Items.Add(strIn);
                break;

            case INVOKE_ENUMDB.ENUMDB_NEWDATABASE:
                this.lboxDatabases.Items.Add(strIn);
                break;

            case INVOKE_ENUMDB.ENUMDB_COMPLETE:
                // Enable Find buttons.
                this.cmdFindDatabases.Enabled = true;
                this.cmdFindVolumes.Enabled   = true;
                break;

            case INVOKE_ENUMDB.STATUS_MESSAGE:
                MessageBox.Show(strIn, m_strAppName);
                break;
            }
        }
Beispiel #2
0
        private void ThreadMainEnumDB()
        {
            if (m_bVolume) // Enumerate volumes.
            {
                Guid   guid = new Guid("ffffffffffffffffffffffffffffffff");
                int    cch  = 32;
                string str  = new String('\0', cch);
                while (Rapi.CeEnumDBVolumes(ref guid, str, cch) ==
                       Rapi.RAPI_TRUE && m_bContinue)
                {
                    strBuffer = str;
                    itReason  = INVOKE_ENUMDB.ENUMDB_NEWVOLUME;
                    m_ctlInvokeTarget.Invoke(m_deleCallback);
                }
            }
            else         // Enumerate databases.
            {
                short  cRecords = 0;
                IntPtr pfdbAll  = IntPtr.Zero;
                Rapi.CeFindAllDatabases(0,
                                        Rapi.FAD.FAD_NAME | Rapi.FAD.FAD_NUM_RECORDS,
                                        ref cRecords,
                                        ref pfdbAll);

                IntPtr pfdb = pfdbAll;
                while (cRecords > 0)
                {
                    // Set pointer to next record.
                    Rapi.CEDB_FIND_DATA dbfd =
                        (Rapi.CEDB_FIND_DATA)
                        Marshal.PtrToStructure(
                            pfdb, typeof(Rapi.CEDB_FIND_DATA));

                    // Post name to listbox.
                    strBuffer = dbfd.DbInfo.szDbaseName + " (" +
                                dbfd.DbInfo.wNumRecords + " records)";
                    itReason = INVOKE_ENUMDB.ENUMDB_NEWDATABASE;
                    m_ctlInvokeTarget.Invoke(m_deleCallback);

                    // Get ready for next loop.
                    pfdb = (IntPtr)((int)pfdb + Marshal.SizeOf(dbfd));
                    cRecords--;
                } // while

                // Free memory returned by CeFindAllDatabases.
                Rapi.CeRapiFreeBuffer(pfdbAll);
            } // if

            // Notify main thread that we are done.
            itReason = INVOKE_ENUMDB.ENUMDB_COMPLETE;
            m_ctlInvokeTarget.Invoke(m_deleCallback);

            // Mark thread as done.
            m_thrd = null;
        }