{"id":417,"date":"2010-12-21T14:34:50","date_gmt":"2010-12-21T14:34:50","guid":{"rendered":"https:\/\/ibex.tech\/visualcpp\/?p=417"},"modified":"2026-06-17T09:25:37","modified_gmt":"2026-06-17T08:25:37","slug":"registry","status":"publish","type":"post","link":"https:\/\/ibex.tech\/visualcpp\/registry\/registry","title":{"rendered":"Registry"},"content":{"rendered":"<p>Search the Registry Class&#8217; in help &#8211; lots of examples<\/p>\n<pre><code>using namespace Microsoft::Win32;<\/code><\/pre>\n<p>Help has good example for the registry class.<\/p>\n<h4>Read A Registry Value<\/h4>\n<pre><code>\r\n\tString ^VlcInstallPath;\r\n\tVlcInstallPath = Convert::ToString(Registry::GetValue(\"HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\VideoLAN\\\\VLC\", \"InstallDir\", \"\"));\r\n<\/code><\/pre>\n<h4>Working Example Of Reading FTDI USB Chip entries in the Registry<\/h4>\n<pre><code>\r\n\/\/----- CHECK REGISTRY TO FIND MATCHING FDTI DEVICES AND ONLY INCLUDE THOSE COMM PORTS -----\r\n\/\/(We only show comm ports for our devices that are currently connected)\r\n\/\/This is the registry path we're interested in (taken from FTDI web site):-\r\n\/\/HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\FTDIBUS\\VID_VID+PID_PID+Serial_Number\\0000\\DeviceParameters\\PortName\r\n\r\n\/\/Retrieve all the subkeys for the specified key.\r\nRegistryKey ^rkey = Registry::LocalMachine;\r\nrkey = rkey-&gt;OpenSubKey(L\"SYSTEM\\\\CurrentControlSet\\\\Enum\\\\FTDIBUS\");\r\narray&lt;String^&gt;^names = rkey-&gt;GetSubKeyNames();\r\n\r\nfor each (String^ name in names)\r\n{\r\n\t\/\/----- CHECK NEXT FTDI DEVICE IN THE REGISTRY -----\r\n\t\/\/name = VID_VID+PID_PID+Serial_Number\r\n\r\n\t\/\/Get Serial Number portion\r\n\tCharPosn = name-&gt;LastIndexOf(\"+\");\r\n\tif (CharPosn &gt;= 0)\r\n\t{\r\n\t\tSerialNumber = name-&gt;Substring(CharPosn + 1);\t\/\/Returns rest of string starting at character posn #\r\n\t\tSerialNumber = SerialNumber-&gt;Trim();\r\n\r\n\t\tif ((SerialNumber-&gt;Length == 9) &amp;&amp; (SerialNumber-&gt;Contains(\"KPS\")))\r\n\t\t{\r\n\t\t\t\/\/THIS IS A LIBRA POWER SUPPLY - GET THE COMM PORT FIELD\r\n\t\t\trkey = rkey-&gt;OpenSubKey(name);\r\n\t\t\trkey = rkey-&gt;OpenSubKey(L\"0000\\\\Device Parameters\");\r\n\t\t\tPort = Convert::ToString(rkey-&gt;GetValue(\"PortName\"));\t\t\/\/Will be COM1 etc\r\n\r\n\t\t}\r\n\t}\r\n\r\n}\r\nrkey-&gt;Close();\r\n<\/code><\/pre>\n<h4>Writing To Registry<\/h4>\n<p>On Windows Vista access permission must be available to modify a registry value.  If you are creating the registry entry you can specify that all users have access, but if not then you will often find that UAC will not allow access under Vista and above.<br \/>\nFor an example see Serial Port&gt;FTDI USB Devices &gt; Setting Latency<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Search the Registry Class&#8217; in help &#8211; lots of examples using namespace Microsoft::Win32; Help has good example for the registry class. Read A Registry Value String ^VlcInstallPath; VlcInstallPath = Convert::ToString(Registry::GetValue(&#8220;HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\VideoLAN\\\\VLC&#8221;, &#8220;InstallDir&#8221;, &#8220;&#8221;)); Working Example Of Reading FTDI USB Chip entries in the Registry \/\/&#8212;&#8211; CHECK REGISTRY TO FIND MATCHING FDTI DEVICES AND ONLY INCLUDE THOSE [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[51],"tags":[],"class_list":["post-417","post","type-post","status-publish","format-standard","hentry","category-registry"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/417","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/comments?post=417"}],"version-history":[{"count":6,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/417\/revisions"}],"predecessor-version":[{"id":1085,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/417\/revisions\/1085"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/media?parent=417"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/categories?post=417"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/tags?post=417"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}