All pastes #614622 Raw Edit

Something

public text v1 · immutable
·published 2007-07-11 17:51 UTC
rendered paste body
function removeShortcut(hMSI)
    STRING szKey, szName, svScPath, svPropValue, svFSc, svDocPath,svRetPath;
    NUMBER nvType, nvSize, nResult, nvBufferSize, stPos;
    HWND runningDb, shortcutNames, scRecords; 
    
begin             
	RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE); 
	runningDb = MsiGetActiveDatabase(hMSI);
	MsiDatabaseOpenView(runningDb,"SELECT * FROM `Shortcut`", shortcutNames);
	MsiViewExecute(shortcutNames,NULL);
	while(MsiViewFetch(shortcutNames, scRecords) != ERROR_NO_MORE_ITEMS)
		nvBufferSize = 256;
		MsiRecordGetString(scRecords, 3, svPropValue, nvBufferSize);
		StrSub(svPropValue,svPropValue,StrFind(svPropValue,"|")+1,StrLengthChars(svPropValue));
		endwhile;
	MsiViewClose(shortcutNames);	
	szKey = REG_KEY_USER;
	szName = REG_SC_DIR;
	if (RegDBKeyExist ( szKey )) then
		RegDBGetKeyValueEx (szKey, szName, nvType, svScPath, nvSize);  
		
		svFSc = svScPath + "\\" + svPropValue + ".lnk";	
	endif;
    if (DeleteFile (svFSc) < 0) then 
    		svPropValue = svPropValue + ".lnk";
    		MessageBox("SvPropValue: "+svPropValue,INFORMATION);
    		MsiGetProperty (hMSI,"DesktopFolder",svDocPath,nvBufferSize);
    		stPos = StrFindEx(svDocPath,"\\",3);
    		StrSub(svDocPath,svDocPath,0,stPos+1);
    		MessageBox("SVdockpath: "+svDocPath,INFORMATION);
    		nResult = FindAllFiles (svDocPath,svPropValue,svRetPath, RESET);
    		if (nResult = 0) then
    			while(nResult = 0)
    				MessageBox("Found shortcut: "+svRetPath,INFORMATION);
    				nResult = FindAllFiles(svDocPath, svPropValue, svRetPath,CONTINUE);
    				DeleteFile (svRetPath);
    			endwhile;
    		else
    			MessageBox("There was a problem deleting the desktop shortcut.",INFORMATION);
    		endif;
    endif;
end;