Strongly recommended API plug-ins: pInvoke VS addin

Source: Internet
Author: User

During data backup and recovery today, I encountered a space problem in the path, so I had to seek help from API, search, getmediapathname (), and query MSDN. The speed was too slow. Forget it, PInvoke is a knowledge base that focuses on APIs. However, it was unexpectedly discovered that PInvoke.net has implemented a VS-based plug-in. It is very nice to try it out and cannot be exclusive, I recommend it to you ......
Install PInvokeVsAddin, restart VS, and add PInvoke.net to the menu. OK
Open the project and Insert PInvoke signatures...

Search...

If you are not familiar with the use of APIS, PInvoke provides the help of the website example, "Go to funcation in PInvoke.net", the link is already provided on the plug-in, for example: the getmediapathname plugin automatically navigate to an instance of http://pinvoke.net/default.aspx/kernel32.GetShortPathName, VB, C #, Other.

A simple example:
 

Code
// Http://cnblogs.com/winzheng
Class Program
{
[DllImport ("kernel32.dll", CharSet = CharSet. Auto, SetLastError = true)]
Static extern uint get1_pathname (
[Financialas (UnmanagedType. LPTStr)]
String lpszLongPath,
[Financialas (UnmanagedType. LPTStr)]
StringBuilder lpszShortPath,
Uint cchBuffer );

Static void Main ()
{
Console. WriteLine (getmediapathname (Environment. CurrentDirectory ));
Console. ReadLine ();

}
/// <Summary>
///
/// </Summary>
/// <Param name = "longName"> The long name path </param>
/// <Returns> A short name path string </returns>
Public static string getdomainpathname (string longName)
{
StringBuilder shortNameBuffer = new StringBuilder (256 );
Uint bufferSize = (uint) shortNameBuffer. Capacity;
Uint result = getmediapathname (longName, shortNameBuffer, bufferSize );
If (result! = 0)
Return shortNameBuffer. ToString ();
Return longName;
}


A function that changes the path to the 8.3 format is completed at the moment of motion, is it worth promoting? However, the tool is not just to speed up our development, try not to spend time writing repetitive code. You need to think carefully about unfamiliar technologies to avoid leaving the tool. We will not write anything ....
Strongly recommended... example source code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.