unre@l Δημοσ. 10 Απριλίου 2004 Δημοσ. 10 Απριλίου 2004 Hello people.. loipon... kserei kaneis na mou pei pos boro na ftiakso ena programma to opoio na "koitaei" se kapoion katalogo pou 8a oriso an uparxoun arxeia apo shortcuts kai na apo8ikevei to path tous se metavlites? 8elo na to kano se Visual C++ (verison 7.1) kai se Visual Basic (version 7.1)! euxaristo!
Directx Δημοσ. 11 Απριλίου 2004 Δημοσ. 11 Απριλίου 2004 Για το θέμα των Shortcuts (που είναι το πιο περίπλοκο της όλης διαδικασίας), σκέφτηκα να γράψω κάτι δικό μου, αλλά αφού υπάρχει θέμα στο Win API δες αυτό καλύτερα: > PSS ID Number: Q130698 Authored 25-May-1995 Last modified 30-May-1995 The information in this article applies to: - Microsoft Win32 Software Development Kit (SDK) versions 3.51 and 4.0 SUMMARY The new shell link under Windows 95 (also available for Windows NT after Windows 95 ships) provides applications and users a way to create shortcuts or links to objects in the shells namespace. Some applications need to get the filename and path, given a link or shortcut. The IShellLink OLE Interface implemented by the shell can be used to obtain this information, among other things. MORE INFORMATION A shell link allows the user or an application to access an oject from anywhere in the namespace. Links or shortcuts to objects are stored as binary files. These files contain information such as the path to the object, working directory, the path of the icon used to display the object, the description string, and so on. Given a link or shortcut, applications can use the IShellLink interface and its functions to obtain all the pertinent information about that object. The IShellLink interface supports fucntions such as GetPath(), GetDescription(), Resolve(), GetWorkingDirectory(), and so on. Code Sample ----------- The following code shows how to obtain the filename or path and description of a given link file. // GetLinkInfo() fills the filename and path buffer // with relevant information // hWnd - calling app's window handle. // // lpszLinkName - name of the link file passed into the function. // // lpszPath - the buffer that will receive the filepath name. // HRESULT GetLinkInfo( HWND hWnd, LPCTSTR lpszLinkName, LPSTR lpszPath, LPSTR szDescription) { HRESULT hres; IShellLink *psl; WIN32_FIND_DATA wfd; // Assume Failure to start with: *lpszPath = 0; *lpszDescription = 0; // Call CoCreateInstance to obtain the IShellLink // Interface pointer. This call fails if // CoInitialize is not called, so it is assumed that // CoInitialize has been called. hres = CoCreateInstance( CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID *)&psl ); if ( SUCCEEDED( hres ) ) { IPersistFile *ppf; bRetVal = TRUE; // The IShellLink Interface supports the IPersistFile // interface. Get an interface pointer to it. hres = psl->lpVtbl->QueryInterface(psl, IID_IPersistFile, (LPVOID *)&ppf ); if ( SUCCEEDED( hres ) ) { WORD wsz[MAX_PATH]; //Convert the given link name string to wide character string. MultiByteToWideChar( CP_ACP, 0, lpszLinkName, -1, wsz, MAX_PATH ); //Load the file. hres = ppf->lpVtbl->Load(ppf, wsz, STGM_READ ); if ( SUCCEEDED( hres ) ) { // Resolve the link by calling the Resolve() interface function. hres = psl->lpVtbl->Resolve(psl, hWnd, SLR_ANY_MATCH | SLR_NO_UI); if ( SUCCEEDED( hres ) ) { hres = psl->lpVtbl->GetPath( psl, lpszPath, MAX_PATH, (WIN32_FIND_DATA*)&wfd, SLGP_SHORTPATH ); if(!SUCCEEDED(hres)) return FALSE; hres = psl->lpVtbl->Get(Description(psl, lpszDescription, MAX_PATH ); if(!SUCCEEDED(hres)) return FALSE; } } ppf->lpVtbl->Release(); } psl->lpVtbl->Release(); } return hres; } Ensure that the interface pointers are released when the application is finished using them. For a list of other functions that the IShellLink Interface supports, please see the documentation on the IShellLink interface. NOTE: If applications use C++ instead of C, the interface pointer (psl, ppf) and the lpVtbl variables are implicit. Additional reference words: 4.00 KBCategory: kbprg kbcode kbole KBSubcategory: IShellLink Καλή τύχη!!
Προτεινόμενες αναρτήσεις
Αρχειοθετημένο
Αυτό το θέμα έχει αρχειοθετηθεί και είναι κλειστό για περαιτέρω απαντήσεις.