// Szstartapppath: Click to startProgram // Szaddmedialine: The lpcmdline passed to the main function. // Szdestlnkpath: saved path of the shortcut // Sziconpath: shortcut icon # Ifdef _ Unicode typedef wstring tstring; # Else Typedef String Tstring; # Endif Bool Createlinkfile (maid, maid, maid) {hresult HR = Coinitialize (null ); If (Succeeded (HR) {ishelllink * Pshelllink; HR = Cocreateinstance (clsid_shelllink, null, clsctx_inproc_server, iid_ishelllink ,( Void **)& Pshelllink ); If (Succeeded (HR) {pshelllink ->Setpath (szstartapppath); tstring strtmp = Szstartapppath; Int Nstart = strtmp. find_last_of (_ T ( " /\\ " ); Pshelllink -> Setworkingdirectory (strtmp. substr ( 0 , Nstart). c_str (); pshelllink -> Setarguments (szaddmedialine ); If (Sziconpath) {pshelllink -> Seticonlocation (sziconpath, 0 );} Ipersistfile * Ppersistfile; HR = Pshelllink-> QueryInterface (iid_ipersistfile ,( Void **)& Ppersistfile ); If (Succeeded (HR) {HR = Ppersistfile-> Save (szdestlnkpath, false ); If (Succeeded (HR )){ Return True ;} Ppersistfile -> Release ();} pshelllink -> Release ();} couninitialize ();} Return False ;}