zoukankan      html  css  js  c++  java
  • 利用Everything的DLL实现文件的搜索功能

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;

    namespace EverythingSDK
    {
        
    public partial class Form1 : Form
        {
            
    #region 引用定义
            
    const int EVERYTHING_OK = 0;
            
    const int EVERYTHING_ERROR_MEMORY = 1;
            
    const int EVERYTHING_ERROR_IPC = 2;
            
    const int EVERYTHING_ERROR_REGISTERCLASSEX = 3;
            
    const int EVERYTHING_ERROR_CREATEWINDOW = 4;
            
    const int EVERYTHING_ERROR_CREATETHREAD = 5;
            
    const int EVERYTHING_ERROR_INVALIDINDEX = 6;
            
    const int EVERYTHING_ERROR_INVALIDCALL = 7;

            [DllImport(
    "Everything.dll")]
            
    public static extern int Everything_SetSearch(string lpSearchString);
            [DllImport(
    "Everything.dll")]
            
    public static extern void Everything_SetMatchPath(bool bEnable);
            [DllImport(
    "Everything.dll")]
            
    public static extern void Everything_SetMatchCase(bool bEnable);
            [DllImport(
    "Everything.dll")]
            
    public static extern void Everything_SetMatchWholeWord(bool bEnable);
            [DllImport(
    "Everything.dll")]
            
    public static extern void Everything_SetRegex(bool bEnable);
            [DllImport(
    "Everything.dll")]
            
    public static extern void Everything_SetMax(int dwMax);
            [DllImport(
    "Everything.dll")]
            
    public static extern void Everything_SetOffset(int dwOffset);

            [DllImport(
    "Everything.dll")]
            
    public static extern bool Everything_GetMatchPath();
            [DllImport(
    "Everything.dll")]
            
    public static extern bool Everything_GetMatchCase();
            [DllImport(
    "Everything.dll")]
            
    public static extern bool Everything_GetMatchWholeWord();
            [DllImport(
    "Everything.dll")]
            
    public static extern bool Everything_GetRegex();
            [DllImport(
    "Everything.dll")]
            
    public static extern UInt32 Everything_GetMax();
            [DllImport(
    "Everything.dll")]
            
    public static extern UInt32 Everything_GetOffset();
            [DllImport(
    "Everything.dll")]
            
    public static extern string Everything_GetSearch();
            [DllImport(
    "Everything.dll")]
            
    public static extern int Everything_GetLastError();

            [DllImport(
    "Everything.dll")]
            
    public static extern bool Everything_Query();

            [DllImport(
    "Everything.dll")]
            
    public static extern void Everything_SortResultsByPath();

            [DllImport(
    "Everything.dll")]
            
    public static extern int Everything_GetNumFileResults();
            [DllImport(
    "Everything.dll")]
            
    public static extern int Everything_GetNumFolderResults();
            [DllImport(
    "Everything.dll")]
            
    public static extern int Everything_GetNumResults();
            [DllImport(
    "Everything.dll")]
            
    public static extern int Everything_GetTotFileResults();
            [DllImport(
    "Everything.dll")]
            
    public static extern int Everything_GetTotFolderResults();
            [DllImport(
    "Everything.dll")]
            
    public static extern int Everything_GetTotResults();
            [DllImport(
    "Everything.dll")]
            
    public static extern bool Everything_IsVolumeResult(int nIndex);
            [DllImport(
    "Everything.dll")]
            
    public static extern bool Everything_IsFolderResult(int nIndex);
            [DllImport(
    "Everything.dll")]
            
    public static extern bool Everything_IsFileResult(int nIndex);
            [DllImport(
    "Everything.dll")]
            
    public static extern void Everything_GetResultFullPathName(int nIndex, StringBuilder lpString, int nMaxCount);
            [DllImport(
    "Everything.dll")]
            
    public static extern void Everything_Reset();
            
    #endregion

            
    public Form1()
            {
                InitializeComponent();
            }

            
    private void btnQuery_Click(object sender, EventArgs e)
            {
                
    int i;
                
    const int bufsize = 260;
                StringBuilder buf 
    = new StringBuilder(bufsize);

                Everything_SetSearch(txtKeyWord.Text);

                Everything_Query();

                listResult.Items.Clear();
             
                Text 
    = txtKeyWord.Text + " - " + Everything_GetNumResults() + " 结果";

                
    for (i = 0; i < Everything_GetNumResults(); i++)
                {
                    Everything_GetResultFullPathName(i, buf, bufsize);

                    listResult.Items.Insert(i, buf);
                }
            }
        }
    }
  • 相关阅读:
    牛客挑战赛48E速度即转发【带修莫队,分块】
    P3180[HAOI2016]地图【圆方树,莫队,分块】
    Jetty 教程
    Leetcode 238. Product of Array Except Self
    WebService [Debug] undefined element declaration 's:schema'
    WebService [Debug] java.net.BindException: Can't assign requested address
    SQL Server 四种排序, ROW_NUMBER() /RANK() /DENSE_RANK() /ntile() over()
    Leetcode 110 判断二叉树是否为平衡二叉树
    WebService 使用JDK开发WebService
    WebService [Debug] javax.xml.ws.WebServiceException: Undefined port type
  • 原文地址:https://www.cnblogs.com/chenqingwei/p/2086213.html
Copyright © 2011-2022 走看看