aboutsummaryrefslogtreecommitdiff
path: root/ui.cpp
diff options
context:
space:
mode:
authorsirius-m <sirius-m@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2009-10-02 10:14:05 +0000
committersirius-m <sirius-m@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2009-10-02 10:14:05 +0000
commit6d97df0e992dc5015b5327935ab89923d2dc0ba9 (patch)
treeb04484c5ca71f3c99d1545396fa7efc5e2e36b69 /ui.cpp
parentdba0fd9b6a76897bbb42b2b6dcfb3b84b8558936 (diff)
downloadbitcoin-6d97df0e992dc5015b5327935ab89923d2dc0ba9.tar.xz
startup shortcut works
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@11 1a98c847-1fd6-4fd8-948a-caf3550aa51b
Diffstat (limited to 'ui.cpp')
-rw-r--r--ui.cpp75
1 files changed, 53 insertions, 22 deletions
diff --git a/ui.cpp b/ui.cpp
index 751a50be68..e69630d398 100644
--- a/ui.cpp
+++ b/ui.cpp
@@ -859,18 +859,6 @@ void CMainFrame::OnMenuFileExit(wxCommandEvent& event)
Close(true);
}
-void GenerateBitcoins(bool flag)
-{
- fGenerateBitcoins = flag;
- nTransactionsUpdated++;
- CWalletDB().WriteSetting("fGenerateBitcoins", fGenerateBitcoins);
- if (fGenerateBitcoins)
- if (_beginthread(ThreadBitcoinMiner, 0, NULL) == -1)
- printf("Error: _beginthread(ThreadBitcoinMiner) failed\n");
-
- taskBarIcon->UpdateTooltip();
-}
-
void CMainFrame::OnMenuOptionsGenerate(wxCommandEvent& event)
{
GenerateBitcoins(event.IsChecked());
@@ -3394,24 +3382,67 @@ void ApplyUISettings() {
taskBarIcon->Hide();
// Autostart on system startup?
- if (startOnSysBoot) {
- // Get the startup folder path
- char targetPath[ MAX_PATH ];
- SHGetSpecialFolderPath(0, targetPath, CSIDL_STARTUP, 0);
- strcat(targetPath, "\\bitcoin.lnk");
+ // Get the startup folder shortcut path
+ char linkPath[ MAX_PATH ];
+ SHGetSpecialFolderPath(0, linkPath, CSIDL_STARTUP, 0);
+ strcat(linkPath, "\\Bitcoin.lnk");
- // And the current executable path
- char currentPath[ MAX_PATH ];
- GetModuleFileName(NULL, currentPath, _MAX_PATH + 1);
+ // If the shortcut exists already, remove it for updating
+ remove(linkPath);
- // Create the shortcut
- CreateHardLink(targetPath, currentPath, NULL);
+ if (startOnSysBoot) {
+ CoInitialize(NULL);
+ // Get the current executable path
+ char exePath[ MAX_PATH ];
+ GetModuleFileName(NULL, exePath, _MAX_PATH + 1);
+
+ HRESULT hres = NULL;
+ IShellLink* psl = NULL;
+ // Get a pointer to the IShellLink interface.
+ hres = CoCreateInstance(CLSID_ShellLink, NULL,
+ CLSCTX_INPROC_SERVER, IID_IShellLink,
+ reinterpret_cast<void**>(&psl));
+
+ if (SUCCEEDED(hres))
+ {
+ IPersistFile* ppf = NULL;
+ // Set the path to the shortcut target
+ psl->SetPath(exePath);
+ // Query IShellLink for the IPersistFile interface for
+ // saving the shortcut in persistent storage.
+ hres = psl->QueryInterface(IID_IPersistFile,
+ reinterpret_cast<void**>(&ppf));
+ if (SUCCEEDED(hres))
+ {
+ WCHAR wsz[MAX_PATH];
+ // Ensure that the string is ANSI.
+ MultiByteToWideChar(CP_ACP, 0, linkPath, -1,
+ wsz, MAX_PATH);
+ // Save the link by calling IPersistFile::Save.
+ hres = ppf->Save(wsz, TRUE);
+ ppf->Release();
+ }
+ psl->Release();
+ }
+ CoUninitialize();
}
}
+void GenerateBitcoins(bool flag)
+{
+ fGenerateBitcoins = flag;
+ nTransactionsUpdated++;
+ CWalletDB().WriteSetting("fGenerateBitcoins", fGenerateBitcoins);
+ if (fGenerateBitcoins)
+ if (_beginthread(ThreadBitcoinMiner, 0, NULL) == -1)
+ printf("Error: _beginthread(ThreadBitcoinMiner) failed\n");
+
+ taskBarIcon->UpdateTooltip();
+}
+
// randsendtest to bitcoin address