Author Topic: Startup BCX COM  (Read 241 times)

Robert

  • Hero Member
  • *****
  • Posts: 601
    • View Profile
Startup BCX COM
« on: December 07, 2020, 02:06:05 AM »
When the BCX Help "BCX COM Interface" page Example 2: is run in Windows 10, the output GnotePad.lnk file is placed in

C:\Users\YourUserName\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

I couldn't find the location using information from the internet and had to do a DIR /s from root.

It's nice to see that the code still worked in Windows 10 although, after running the program and rebooting, in the Startup settings NotePad.exe was shown as disabled but that was not correct on my machine which had greeted me with a full screen white light flash of an opened Notepad.

Code: [Select]


DIM Link$
   
 Link$ = Startup_Folder$() + "GnotePad.lnk"
   
 CreateLink("c:\windows\notepad.exe",Link$,"","MS Notepad")
   
 FUNCTION Startup_Folder$()
   DIM A$
   DIM Wshell AS OBJECT
   SET Wshell = CREATEOBJECT("Wscript.Shell")
   A$ = Wshell.SpecialFolders("Startup")
   SET Wshell = NOTHING
   FUNCTION = A$ + "\"
 END FUNCTION
   
 
 FUNCTION CreateLink (Exe$, Link$, Args$, Desc$) AS HRESULT
   DIM hres AS HRESULT
   DIM psl AS IShellLink PTR
   DIM w[MAX_PATH] AS WORD
 
   CoInitialize(NULL)
 
   $IFDEF __cplusplus
     hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,  IID_IShellLink, (LPVOID*)&psl)
   $ELSE
     hres = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,  &IID_IShellLink, (LPVOID*)&psl)
   $ENDIF
 
   IF (SUCCEEDED(hres)) THEN
     DIM ppf AS IPersistFile PTR
     psl->lpVtbl->SetPath(psl, Exe)
     psl->lpVtbl->SetDescription(psl, Desc)
     psl->lpVtbl->SetShowCmd(psl, SW_SHOWMAXIMIZED)
     psl->lpVtbl->SetArguments(psl, Args$ )
 
     $IFDEF __cplusplus
       hres = psl->lpVtbl->QueryInterface(psl, IID_IPersistFile, (LPVOID*)&ppf)
     $ELSE
       hres = psl->lpVtbl->QueryInterface(psl, &IID_IPersistFile, (LPVOID*)&ppf)
     $ENDIF
 
     IF (SUCCEEDED(hres)) THEN
       MultiByteToWideChar(CP_ACP, 0, Link, -1, (LPWSTR)w, MAX_PATH)
       hres = ppf->lpVtbl->Save(ppf, (LPCOLESTR)w, TRUE)
       ppf->lpVtbl->Release(ppf)
     END IF
     psl->lpVtbl->Release(psl)
   END IF
 
   CoUninitialize()
   FUNCTION = hres
 END FUNCTION
 

« Last Edit: December 07, 2020, 03:10:24 AM by Robert »

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 786
    • View Profile
Re: Startup BCX COM
« Reply #1 on: December 07, 2020, 03:20:24 AM »
Here is another Windows Startup folder that I use all the time:
( Yes ... there are (at least) two Startup folders per user. )
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup


I too have programs and shortcuts that also launch from:
C:\Users\MyUserName\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup