当前位置:首页
开发技术指南» 文章正文
    引言:
 

 

    摘要: 小弟昨日开始学vc,觉得比学c++难多了。 我买了一本《深入浅出mfc》,据说是初学者看的, 可我还是看不大懂,怎么办? 请各位高手指点迷津,不胜感激。 ......
 ·怎麼作    »显示摘要«
    摘要: 我有一個exe文件,放在頁面里,怎樣在用戶點擊連接時,就開始運行該exe文件? ......


关于自动启动的问题……,谢谢,多帮忙啦

怎么才能让程序开机自动启动时:  
          1     不在任务栏中显示出来?  
          2     关机是自动执行Form_unload过程?  
 

NO.1   作者: rivershan

注册表中提供了三个这样的键:  
  HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run  
  HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce  
  HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices  
  这三个键字的区别是:  
  Run:此键字下的应用程序在系统启动的时候会自动运行;  
  RunOnce:此键字下的应用程序在系统下一次启动的时候会自动运行,以后不再运行;  
  RunServices:功能和“Run”一样,只是应用程序被启动的时候不同而已。  
 

NO.2   作者: junwhj

Private   Declare   Function   RegCloseKey   Lib   "advapi32.dll"   (ByVal   hKey   As   Long)   As   Long  
  Private   Declare   Function   OSRegSetValueEx   Lib   "advapi32"   Alias   "RegSetValueExA"   (ByVal   hKey   As   Long,   ByVal   lpszValueName   As   String,   ByVal   dwReserved   As   Long,   ByVal   fdwType   As   Long,   lpbData   As   Any,   ByVal   cbData   As   Long)   As   Long  
  Private   Declare   Function   RegOpenKey   Lib   "advapi32.dll"   Alias   "RegOpenKeyA"   (ByVal   hKey   As   Long,   ByVal   lpSubKey   As   String,   phkResult   As   Long)   As   Long  
  Private   Declare   Function   RegisterServiceProcess   Lib   "kernel32"   (ByVal   ProcessID   As   Long,   ByVal   ServiceFlags   As   Long)   As   Long  
  Private   Declare   Function   GetCurrentThread   Lib   "kernel32"   ()   As   Long  
   
  Private   Const   HKEY_LOCAL_MACHINE   =   &H80000002  
  Private   Const   REG_SZ   =   1  
   
  Private   Sub   Form_Load()  
          Dim   strAppPath   As   String  
          Dim   lResult   As   Long  
           
          If   Right(App.Path,   1)   =   "\"   Then  
                  strAppPath   =   App.Path   &   App.EXEName   &   ".exe"  
          Else  
                  strAppPath   =   App.Path   &   "\"   &   App.EXEName   &   ".exe"  
          End   If  
                   
          添加到注册表,启动Windows时打开程序  
          RegOpenKey   HKEY_LOCAL_MACHINE,   "SOFTWARE\Microsoft\Windows\CurrentVersion\RunServices",   lResult  
          OSRegSetValueEx   lResult,   App.EXEName,   0&,   REG_SZ,   ByVal   strAppPath,   LenB(strAppPath)  
          RegCloseKey   lResult  
           
          不在任务栏内显示  
          RegisterServiceProcess   GetCurrentProcessId,   1  
  End   Sub  
 

NO.3   作者: no_lost

Private   Declare   Function   RegCloseKey   Lib   "advapi32.dll"   (ByVal   hKey   As   Long)   As   Long  
  Private   Declare   Function   RegCreateKey   Lib   "advapi32.dll"   Alias   "RegCreateKeyA"   (ByVal   hKey   As   Long,   ByVal   lpSubKey   As   String,   phkResult   As   Long)   As   Long  
  Private   Declare   Function   RegSetValueEx   Lib   "advapi32.dll"   Alias   "RegSetValueExA"   (ByVal   hKey   As   Long,   ByVal   lpValueName   As   String,   ByVal   Reserved   As   Long,   ByVal   dwType   As   Long,   lpData   As   Any,   ByVal   cbData   As   Long)   As   Long                     Note   that   if   you   declare   the   lpData   parameter   as   String,   you   must   pass   it   By   Value.  
  Private   Declare   Function   ShellExecute   Lib   "shell32.dll"   Alias   "ShellExecuteA"   (ByVal   hwnd   As   Long,   ByVal   lpOperation   As   String,   ByVal   lpFile   As   String,   ByVal   lpParameters   As   String,   ByVal   lpDirectory   As   String,   ByVal   nShowCmd   As   Long)   As   Long  
  Private   Declare   Function   GetDesktopWindow   Lib   "user32"   ()   As   Long  
  Private   Const   HKEY_CURRENT_USER   =   &H80000001  
  Private   Const   REG_SZ   =   1       Unicode   nul   terminated   string  
   
  Private   Sub   Command1_Click()  
   
  End   Sub  
   
  Private   Sub   Form_Initialize()  
        Dim   hKey   As   Long  
          Dim   strRunCmd   As   String  
          Dim   retval   As   Long  
          If   UnloadMode   =   vbAppWindows   Then  
          retval   =   ShellExecute(GetDesktopWindow(),   "open",   "C:\WINDOWS\Desktop\音频解霸.lnk",   0,   0,   1)  
           
          strRunCmd   =   "E:\wvbEXE\自动行程序.exe"  
          注册表Software\Microsoft\Windows\CurrentVersion\RunOnce保存开机启动程序。  
          Call   RegCreateKey(HKEY_CURRENT_USER,   "Software\Microsoft\Windows\CurrentVersion\Runonce",   hKey)  
          Call   RegSetValueEx(hKey,   "zmhh",   0&,   REG_SZ,   ByVal   strRunCmd,   Len(strRunCmd)   +   1)  
          Call   RegCloseKey(hKey)  
          MsgBox   "下次开机程序会自动启动"  
          End   If  
         
          End  
  End   Sub


    摘要: 有一listctrl,为list风格(注意,不是report),想设置它的列宽,按msdn上所说使用setcolumnwidth(-1,cx),发现设置不了,setcolumnwidth(0,cx)倒是设置到了,不过无论cx为什么值列宽都是一个长度。 我都胡涂了,搞不清楚,是哪里弄掉了或错了,是不是需要某个style啊。大家给个提示。 ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE