C # Read the file that the shortcut points to

Source: Internet
Author: User

[Flags ()] Public enumslr_flags {slr_no_ui=0x1, Slr_any_match=0x2, Slr_update=0x4, Slr_noupdate=0x8, Slr_nosearch=0x10, Slr_notrack=0x20, Slr_nolinkinfo=0x40, Slr_invoke_msi=0x80        }
[Flags ()] Public enumslgp_flags {Slgp_shortpath=0x1, Slgp_uncpriority=0x2, Slgp_rawpath=0x4} [StructLayoutAttribute (LayoutKind.Sequential, CharSet=CharSet.Unicode)]//Unicode version Public structWin32_find_data { Public intdwfileattributes; PublicFILETIME Ftcreationtime; PublicFILETIME Ftlastaccesstime; PublicFILETIME Ftlastwritetime; Public intNfilesizehigh; Public intNfilesizelow; Public intdwReserved0; Public intdwReserved1; [MarshalAs (UnmanagedType.ByValTStr, SizeConst=MAX_PATH)] Public stringcFileName; [MarshalAs (UnmanagedType.ByValTStr, SizeConst= -)] Public stringCalternatefilename; Private Const intMAX_PATH =260; } [ComImport (), InterfaceType (Cominterfacetype.interfaceisiunknown), Guid ("000214f9-0000-0000-c000-000000000046")] //Unicode version Public InterfaceIShellLink {voidGetPath ([Out (), MarshalAs (UNMANAGEDTYPE.LPWSTR)] StringBuilder pszfile,intCchmaxpath, outwin32_find_data pfd,slgp_flags fflags); voidGetidlist ( outIntPtr ppidl); voidsetidlist (IntPtr pidl); voidGetDescription ([Out (), MarshalAs (UNMANAGEDTYPE.LPWSTR)] StringBuilder pszname,intcchmaxname); voidsetdescription ([MarshalAs (UNMANAGEDTYPE.LPWSTR)]stringpszname); voidGetworkingdirectory ([Out (), MarshalAs (UNMANAGEDTYPE.LPWSTR)] StringBuilder Pszdir,intCchmaxpath); voidsetworkingdirectory ([MarshalAs (UNMANAGEDTYPE.LPWSTR)]stringPszdir); voidgetarguments ([Out (), MarshalAs (UNMANAGEDTYPE.LPWSTR)] StringBuilder Pszargs,intCchmaxpath); voidsetarguments ([MarshalAs (UNMANAGEDTYPE.LPWSTR)]stringPszargs); voidGetHotKey ( out ShortPwhotkey); voidSetHotKey ( ShortWhotkey); voidGetshowcmd ( out intpishowcmd); voidSetshowcmd (intishowcmd); voidGeticonlocation ([Out (), MarshalAs (UNMANAGEDTYPE.LPWSTR)] StringBuilder Psziconpath,intCchiconpath, out intPiicon); voidseticonlocation ([MarshalAs (UNMANAGEDTYPE.LPWSTR)]stringPsziconpath,intIicon); voidSetrelativepath ([MarshalAs (UNMANAGEDTYPE.LPWSTR)]stringPszpathrel,intdwreserved); voidResolve (IntPtr hwnd,slr_flags fflags); voidSetPath ([MarshalAs (UNMANAGEDTYPE.LPWSTR)]stringpszfile); } [ComImport (), Guid ("00021401-0000-0000-c000-000000000046")] Public classShelllink {}Private voidForm1_Load (Objectsender, EventArgs e) {IShellLink Vshelllink= (IShellLink)NewShelllink (); UCOMIPersistFile Vpersistfile= Vshelllink asUCOMIPersistFile; Vpersistfile.load (@"C:\Users\guwei4037\Desktop\Adobe Flash Builder 4.6.lnk",0); StringBuilder Vstringbuilder=NewStringBuilder (260); Win32_find_data Vwin32_find_data; Vshelllink.getpath (Vstringbuilder, vstringbuilder.capacity, outVwin32_find_data, Slgp_flags. Slgp_rawpath); Text=vstringbuilder.tostring (); MessageBox.Show (Text);//result}

C # Read the file that the shortcut points to

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.