Close(true);\r
}\r
\r
-void GenerateBitcoins(bool flag)\r
-{\r
- fGenerateBitcoins = flag;\r
- nTransactionsUpdated++;\r
- CWalletDB().WriteSetting("fGenerateBitcoins", fGenerateBitcoins);\r
- if (fGenerateBitcoins)\r
- if (_beginthread(ThreadBitcoinMiner, 0, NULL) == -1)\r
- printf("Error: _beginthread(ThreadBitcoinMiner) failed\n");\r
-\r
- taskBarIcon->UpdateTooltip();\r
-}\r
-\r
void CMainFrame::OnMenuOptionsGenerate(wxCommandEvent& event)\r
{\r
GenerateBitcoins(event.IsChecked());\r
taskBarIcon->Hide();\r
\r
// Autostart on system startup?\r
- if (startOnSysBoot) {\r
- // Get the startup folder path\r
- char targetPath[ MAX_PATH ];\r
- SHGetSpecialFolderPath(0, targetPath, CSIDL_STARTUP, 0);\r
- strcat(targetPath, "\\bitcoin.lnk");\r
+ // Get the startup folder shortcut path\r
+ char linkPath[ MAX_PATH ];\r
+ SHGetSpecialFolderPath(0, linkPath, CSIDL_STARTUP, 0);\r
+ strcat(linkPath, "\\Bitcoin.lnk");\r
\r
- // And the current executable path\r
- char currentPath[ MAX_PATH ];\r
- GetModuleFileName(NULL, currentPath, _MAX_PATH + 1);\r
+ // If the shortcut exists already, remove it for updating\r
+ remove(linkPath);\r
\r
- // Create the shortcut\r
- CreateHardLink(targetPath, currentPath, NULL);\r
+ if (startOnSysBoot) {\r
+ CoInitialize(NULL);\r
+ // Get the current executable path\r
+ char exePath[ MAX_PATH ];\r
+ GetModuleFileName(NULL, exePath, _MAX_PATH + 1);\r
+\r
+ HRESULT hres = NULL;\r
+ IShellLink* psl = NULL;\r
+ // Get a pointer to the IShellLink interface.\r
+ hres = CoCreateInstance(CLSID_ShellLink, NULL,\r
+ CLSCTX_INPROC_SERVER, IID_IShellLink,\r
+ reinterpret_cast<void**>(&psl));\r
+\r
+ if (SUCCEEDED(hres))\r
+ {\r
+ IPersistFile* ppf = NULL;\r
+ // Set the path to the shortcut target\r
+ psl->SetPath(exePath);\r
+ // Query IShellLink for the IPersistFile interface for\r
+ // saving the shortcut in persistent storage.\r
+ hres = psl->QueryInterface(IID_IPersistFile,\r
+ reinterpret_cast<void**>(&ppf));\r
+ if (SUCCEEDED(hres))\r
+ {\r
+ WCHAR wsz[MAX_PATH];\r
+ // Ensure that the string is ANSI.\r
+ MultiByteToWideChar(CP_ACP, 0, linkPath, -1,\r
+ wsz, MAX_PATH);\r
+ // Save the link by calling IPersistFile::Save.\r
+ hres = ppf->Save(wsz, TRUE);\r
+ ppf->Release();\r
+ }\r
+ psl->Release();\r
+ }\r
+ CoUninitialize();\r
}\r
}\r
\r
\r
\r
\r
+void GenerateBitcoins(bool flag)\r
+{\r
+ fGenerateBitcoins = flag;\r
+ nTransactionsUpdated++;\r
+ CWalletDB().WriteSetting("fGenerateBitcoins", fGenerateBitcoins);\r
+ if (fGenerateBitcoins)\r
+ if (_beginthread(ThreadBitcoinMiner, 0, NULL) == -1)\r
+ printf("Error: _beginthread(ThreadBitcoinMiner) failed\n");\r
+\r
+ taskBarIcon->UpdateTooltip();\r
+}\r
+\r
\r
\r
// randsendtest to bitcoin address\r