当前位置: 代码迷 >> VC >> 程序刷新注册表立即生效,该怎么处理
  详细解决方案

程序刷新注册表立即生效,该怎么处理

热度:3344   发布时间:2013-02-25 00:00:00.0
程序刷新注册表立即生效
我用程序修改了注册表,隐藏了F盘,但是手动刷新好多次才能隐藏,我想有没有一种办法,能刷新注册表使之马上生效呢?请高人指点。还有我修改了硬盘的分区表,但是需要重启之后才能生效,有没有什么办法能立刻生效呢?期待高人回答

------解决方案--------------------------------------------------------
试试向windows系统发送广播消息如何?

::SendMessage(HWND_BROADCAST,WM_SETTINGCHANGE,NULL,NULL);

MSDN中是这样解释的(英文):

SendMessage
The SendMessage function sends the specified message to a window or windows. The function calls the window procedure for the specified window and does not return until the window procedure has processed the message. The PostMessage function, in contrast, posts a message to a thread's message queue and returns immediately. 

LRESULT SendMessage(
HWND hWnd, // handle of destination window
UINT Msg, // message to send
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
 
Parameters
hWnd 
Handle to the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST, the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows. 
Msg 
Specifies the message to be sent. 
wParam 
Specifies additional message-specific information. 
lParam 
Specifies additional message-specific information. 



  相关解决方案