{"id":238,"date":"2018-04-14T15:23:40","date_gmt":"2018-04-14T15:23:40","guid":{"rendered":"https:\/\/www.unsafehex.com\/?p=238"},"modified":"2024-09-27T17:29:18","modified_gmt":"2024-09-27T17:29:18","slug":"undocumented-function-regrenamekey","status":"publish","type":"post","link":"https:\/\/www.unsafehex.com\/index.php\/2018\/04\/14\/undocumented-function-regrenamekey\/","title":{"rendered":"Undocumented function &#8220;RegRenameKey&#8221;"},"content":{"rendered":"<p>Whilst learning some bits and pieces about the Windows API, I found a function that I wanted to use which <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/ms724875(v=vs.85).aspx\" target=\"_blank\" rel=\"noopener\">does not appear to be documented on MSDN<\/a>, &#8220;RegRenameKey&#8221;. Although Visual Studio will helpfully inform you of the datatypes required, it does not tell you what is expected within the datatypes. Since the answer doesn&#8217;t seem to be out there just yet I thought I&#8217;d do a quick writeup. The definition for the function is as follows:<\/p>\n<pre>LSTATUS WINAPI RegRenameKey( \r\n  _In_\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0HKEY \u00a0\u00a0\u00a0hKey, \r\n  _In_ \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0LPCTSTR lpSubKeyName,\r\n  _In_         LPCTSTR lpNewKeyName \r\n);<\/pre>\n<p>I assumed that lpSubKeyName and lpNewKeyName would accept the same form of input as the registry path expected for RegKeyCreate, e.g. &#8220;Software\\\\MyProduct\\\\MyKey&#8221;. However, attempting to use this returns error code 0x57 &#8220;The parameter is incorrect&#8221;. This is because lpNewKeyName seems to expect\u00a0<strong>just<\/strong> a name without the path. A valid call looks like this:<\/p>\n<pre> TCHAR keyname[] = L\"Software\\\\testkey\";\r\n TCHAR newkeyname[] = L\"testkey2\";\r\n LSTATUS renameerr = RegRenameKey(HKEY_CURRENT_USER, keyname, newkeyname);<\/pre>\n<p>Not a particularly difficult one, but hopefully this will save people some time!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Whilst learning some bits and pieces about the Windows API, I found a function that I wanted to use which does not appear to be documented on MSDN, &#8220;RegRenameKey&#8221;. Although Visual Studio will helpfully inform you of the datatypes required, it does not tell you what is expected within the datatypes. Since the answer doesn&#8217;t [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[76,12],"tags":[77,79,78],"class_list":["post-238","post","type-post","status-publish","format-standard","hentry","category-programming","category-tutorials-and-guides","tag-c","tag-programming","tag-registry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Undocumented function &quot;RegRenameKey&quot; &#8211; unsafehex<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.unsafehex.com\/index.php\/2018\/04\/14\/undocumented-function-regrenamekey\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Undocumented function &quot;RegRenameKey&quot; &#8211; unsafehex\" \/>\n<meta property=\"og:description\" content=\"Whilst learning some bits and pieces about the Windows API, I found a function that I wanted to use which does not appear to be documented on MSDN, &#8220;RegRenameKey&#8221;. Although Visual Studio will helpfully inform you of the datatypes required, it does not tell you what is expected within the datatypes. Since the answer doesn&#8217;t [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.unsafehex.com\/index.php\/2018\/04\/14\/undocumented-function-regrenamekey\/\" \/>\n<meta property=\"og:site_name\" content=\"unsafehex\" \/>\n<meta property=\"article:published_time\" content=\"2018-04-14T15:23:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-09-27T17:29:18+00:00\" \/>\n<meta name=\"author\" content=\"http_error_418\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@http_error_418\" \/>\n<meta name=\"twitter:site\" content=\"@http_error_418\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"http_error_418\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.unsafehex.com\/index.php\/2018\/04\/14\/undocumented-function-regrenamekey\/\",\"url\":\"https:\/\/www.unsafehex.com\/index.php\/2018\/04\/14\/undocumented-function-regrenamekey\/\",\"name\":\"Undocumented function \\\"RegRenameKey\\\" &#8211; unsafehex\",\"isPartOf\":{\"@id\":\"https:\/\/www.unsafehex.com\/#website\"},\"datePublished\":\"2018-04-14T15:23:40+00:00\",\"dateModified\":\"2024-09-27T17:29:18+00:00\",\"author\":{\"@id\":\"https:\/\/www.unsafehex.com\/#\/schema\/person\/69a7fc817171b5a3c4770875a1918652\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.unsafehex.com\/index.php\/2018\/04\/14\/undocumented-function-regrenamekey\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.unsafehex.com\/index.php\/2018\/04\/14\/undocumented-function-regrenamekey\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.unsafehex.com\/index.php\/2018\/04\/14\/undocumented-function-regrenamekey\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.unsafehex.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Undocumented function &#8220;RegRenameKey&#8221;\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.unsafehex.com\/#website\",\"url\":\"https:\/\/www.unsafehex.com\/\",\"name\":\"unsafehex\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.unsafehex.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.unsafehex.com\/#\/schema\/person\/69a7fc817171b5a3c4770875a1918652\",\"name\":\"http_error_418\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.unsafehex.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/fe9a4cdd9d9f058529884ce588767baf?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/fe9a4cdd9d9f058529884ce588767baf?s=96&d=mm&r=g\",\"caption\":\"http_error_418\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Undocumented function \"RegRenameKey\" &#8211; unsafehex","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.unsafehex.com\/index.php\/2018\/04\/14\/undocumented-function-regrenamekey\/","og_locale":"en_GB","og_type":"article","og_title":"Undocumented function \"RegRenameKey\" &#8211; unsafehex","og_description":"Whilst learning some bits and pieces about the Windows API, I found a function that I wanted to use which does not appear to be documented on MSDN, &#8220;RegRenameKey&#8221;. Although Visual Studio will helpfully inform you of the datatypes required, it does not tell you what is expected within the datatypes. Since the answer doesn&#8217;t [&hellip;]","og_url":"https:\/\/www.unsafehex.com\/index.php\/2018\/04\/14\/undocumented-function-regrenamekey\/","og_site_name":"unsafehex","article_published_time":"2018-04-14T15:23:40+00:00","article_modified_time":"2024-09-27T17:29:18+00:00","author":"http_error_418","twitter_card":"summary_large_image","twitter_creator":"@http_error_418","twitter_site":"@http_error_418","twitter_misc":{"Written by":"http_error_418","Estimated reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.unsafehex.com\/index.php\/2018\/04\/14\/undocumented-function-regrenamekey\/","url":"https:\/\/www.unsafehex.com\/index.php\/2018\/04\/14\/undocumented-function-regrenamekey\/","name":"Undocumented function \"RegRenameKey\" &#8211; unsafehex","isPartOf":{"@id":"https:\/\/www.unsafehex.com\/#website"},"datePublished":"2018-04-14T15:23:40+00:00","dateModified":"2024-09-27T17:29:18+00:00","author":{"@id":"https:\/\/www.unsafehex.com\/#\/schema\/person\/69a7fc817171b5a3c4770875a1918652"},"breadcrumb":{"@id":"https:\/\/www.unsafehex.com\/index.php\/2018\/04\/14\/undocumented-function-regrenamekey\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.unsafehex.com\/index.php\/2018\/04\/14\/undocumented-function-regrenamekey\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.unsafehex.com\/index.php\/2018\/04\/14\/undocumented-function-regrenamekey\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.unsafehex.com\/"},{"@type":"ListItem","position":2,"name":"Undocumented function &#8220;RegRenameKey&#8221;"}]},{"@type":"WebSite","@id":"https:\/\/www.unsafehex.com\/#website","url":"https:\/\/www.unsafehex.com\/","name":"unsafehex","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.unsafehex.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/www.unsafehex.com\/#\/schema\/person\/69a7fc817171b5a3c4770875a1918652","name":"http_error_418","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.unsafehex.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/fe9a4cdd9d9f058529884ce588767baf?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/fe9a4cdd9d9f058529884ce588767baf?s=96&d=mm&r=g","caption":"http_error_418"}}]}},"_links":{"self":[{"href":"https:\/\/www.unsafehex.com\/index.php\/wp-json\/wp\/v2\/posts\/238"}],"collection":[{"href":"https:\/\/www.unsafehex.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.unsafehex.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.unsafehex.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.unsafehex.com\/index.php\/wp-json\/wp\/v2\/comments?post=238"}],"version-history":[{"count":3,"href":"https:\/\/www.unsafehex.com\/index.php\/wp-json\/wp\/v2\/posts\/238\/revisions"}],"predecessor-version":[{"id":243,"href":"https:\/\/www.unsafehex.com\/index.php\/wp-json\/wp\/v2\/posts\/238\/revisions\/243"}],"wp:attachment":[{"href":"https:\/\/www.unsafehex.com\/index.php\/wp-json\/wp\/v2\/media?parent=238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.unsafehex.com\/index.php\/wp-json\/wp\/v2\/categories?post=238"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.unsafehex.com\/index.php\/wp-json\/wp\/v2\/tags?post=238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}