C # Make the Registry effective immediately after modification

Source: Internet
Author: User

The modification takes effect without restarting the computer.

Const int wm_settingchange = 0x001a;

Const int hwnd_broadcast = 0 xFFFF;

Intptr result1;

Public Enum sendmessagetimeoutflags: uint

{

Smto_normal = 0x0000,

Smto_block = 0x0001,

Smto_abortifhung = 0x0002,

Smto_notimeoutifnothung = 0x0008

}

[Dllimport ("user32.dll", setlasterror = true, charset = charset. Auto)]

Public static extern intptr sendmessagetimeout (

Intptr when whandle,

Uint MSG,

Intptr wparam,

Intptr lparam,

Sendmessagetimeoutflags flags,

Uint timeout,

Out intptr result

);

Public void changereg ()

{

// Notify all EnabledProgramRegistry to modify

Sendmessagetimeout (New intptr (hwnd_broadcast), wm_settingchange, intptr. Zero, intptr. Zero, sendmessagetimeoutflags. smto_normal, 1000, out result1 );

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.