强烈推荐的API插件:pInvoke VS addin

      今天在数据备份和恢复时,遇到了路径中空格问题,只好求助API,搜,GetShortPathName(),查MSDN,速度太慢了,算了,PInvoke一个专注API的知识库,不过意外的发现,PInvoke.net 做了一个基于VS的插件,想的周到,试用一下,很爽,不敢独享,推荐给大家......
      安装PInvokeVsAddin, 重启VS,菜单上多了一项PInvoke.net,OK
      打开项目,Insert PInvoke signatures...
      PInvoke1.jpg
      开搜...
      PInvoke3.jpg
      如果对API的使用不熟悉,PInvoke 提供了网站的例子帮助,"Go to funcation in PInvoke.net",链接已经在插件上提供了,例如:GetShortPathName插件自动导航到  http://pinvoke.net/default.aspx/kernel32.GetShortPathName ,VB,C#,Other 的实例.
      PInvoke4.jpg
 一个简单的例子:    
 

ContractedBlock.gifExpandedBlockStart.gifCode
 //http://cnblogs.com/winzheng    
   class Program
    {
        [DllImport(
"kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        
static extern uint GetShortPathName(
          [MarshalAs(UnmanagedType.LPTStr)]
             
string lpszLongPath,
          [MarshalAs(UnmanagedType.LPTStr)]
           StringBuilder lpszShortPath,
          
uint cchBuffer);

        
static void Main()
        {
            Console.WriteLine(GetShortPathName(Environment.CurrentDirectory));
            Console.ReadLine();

        }
        
/// <summary>
        
///
        
/// </summary>
        
/// <param name="longName">The long name path</param>
        
/// <returns>A short name path string</returns>
        public static string GetShortPathName(string longName)
        {
            StringBuilder shortNameBuffer 
= new StringBuilder(256);
            
uint bufferSize = (uint) shortNameBuffer.Capacity;
            
uint result = GetShortPathName(longName, shortNameBuffer, bufferSize);
            
if (result != 0)
                
return shortNameBuffer.ToString();
            
return longName;
        }

        一个将路径改为8.3格式的功能在动一动鼠标的瞬间完成,是不是值得推进,不过,工具只不是加快我们的开发速度,尽量不去把时间花到写重复代码上,对于不熟悉的技术还需要自己仔细琢磨,以免离开工具,我们什么都不会写了....
       强烈推荐...例子源码


转载于:https://www.cnblogs.com/winzheng/archive/2008/03/13/1103001.html

PInvoke插件 RedGate.PInvokeExtension VS平台调用插件 PInvoke 平台调用 调用C++ 调用系统 C#调C++, Search Module: Directory Constants Delegates Enums Interfaces Structures Desktop Functions: advapi32 avifil32 cards cfgmgr32 comctl32 comdlg32 credui crypt32 dbghelp dbghlp dbghlp32 dhcpsapi difxapi dmcl40 dnsapi dtl dwmapi faultrep fbwflib fltlib fwpuclnt gdi32 gdiplus getuname glu32 glut32 gsapi hhctrl hid hlink httpapi icmp imm32 iphlpapi iprop irprops kernel32 mapi32 MinCore mpr mqrt mscorsn msdelta msdrm msi msports msvcrt ncrypt netapi32 ntdll ntdsapi odbc32 odbccp32 ole32 oleacc oleaut32 opengl32 pdh powrprof printui propsys psapi pstorec query quickusb rasapi32 rpcrt4 scarddlg secur32 setupapi shell32 shlwapi twain_32 unicows urlmon user32 userenv uxtheme version wer wevtapi winfax winhttp wininet winmm winscard winspool wintrust winusb wlanapi ws2_32 wtsapi32 xolehlp xpsprint Smart Device Functions: aygshell coredll ipaqutil rapi Glossary distributed computing LibHolocaust Marshaling Marshalling Marshalling PInvoke test pinvoke Show Recent Changes Subscribe (RSS) Misc. Pages Comments FAQ Helpful Tools Playground Suggested Reading Website TODO List Support Forum Download Visual Studio Add-In Terms of Use Privacy Policy Create page PInvoke (glossary) Summary The mechanism provided by the CLR that enables managed code to call static DLL exports. Access PInvoke.net directly from VS: Terms of Use Edit This Page Find References Show Printable Version Revisions Show changes
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值