MCPcopy Create free account
hub / github.com/MaxBelkov/visualsyslog / CreateLink

Function CreateLink

sourcecommon/utils.cpp:933–971  ·  view source on GitHub ↗

---------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

931#endif
932//---------------------------------------------------------------------------
933HRESULT CreateLink(LPCSTR lpszPathObj, LPCSTR lpszWorkDir,
934 LPSTR lpszPathLink, LPSTR lpszDesc, LPSTR lpszArgument)
935{
936 HRESULT hres;
937 IShellLink *psl;
938 CoInitialize(NULL);
939 hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&psl);
940
941 if( SUCCEEDED(hres) )
942 {
943 IPersistFile *ppf;
944 // ���� � ���������
945 psl->SetPath(lpszPathObj);
946 // ������� ������� ��� ��������
947 if( lstrlen(lpszWorkDir) > 0 )
948 {
949 psl->SetWorkingDirectory(lpszWorkDir);
950 }
951 else
952 {
953 psl->SetWorkingDirectory(AnsiString(ExtractFilePath(lpszPathObj)).c_str());
954 }
955 // �������� ������
956 psl->SetDescription(lpszDesc);
957 // ��������� ������ ��� ��������
958 psl->SetArguments(lpszArgument);
959 hres = psl->QueryInterface(IID_IPersistFile, (void**)&ppf);
960 if( SUCCEEDED(hres) )
961 {
962 wchar_t wsz[MAX_PATH];
963 MultiByteToWideChar(CP_ACP, 0, lpszPathLink, -1, wsz, MAX_PATH);
964 hres = ppf->Save(wsz, true);
965 ppf->Release();
966 }
967 psl->Release();
968 }
969 CoUninitialize();
970 return hres;
971}
972//---------------------------------------------------------------------------
973//---------------------------------------------------------------------------
974//---------------------------------------------------------------------------

Callers 1

CreateShortcutFunction · 0.85

Calls 1

SaveMethod · 0.45

Tested by

no test coverage detected