Note that there are some explanatory texts on larger screens.

plurals
  1. POWix: Add to Listbox from C++ Custom Action
    primarykey
    data
    text
    <p>Hi i'm trying to check the COM Ports on a users machine and then insert them into a listbox via a custom action in c++. Although it is not displaying the information and when I debug all it is saying is "Function Failed To Execute" This is my Wix code for the listbox:</p> <pre><code> &lt;Control Id="ListBoxID" Type="ListBox" Property="COMPORT" Width="80" Height="40" X="80" Y="165" Indirect="no"&gt; &lt;ListBox Property="COMPORT"&gt; &lt;/ListBox&gt; &lt;Condition Action="hide"&gt;(DEVICETYPE = "1")&lt;/Condition&gt; &lt;Condition Action="show"&gt;(DEVICETYPE = "2")&lt;/Condition&gt; &lt;Condition Action="show"&gt;(DEVICETYPE = "3")&lt;/Condition&gt; &lt;Condition Action="hide"&gt;(DEVICETYPE = "4")&lt;/Condition&gt; &lt;/Control&gt; </code></pre> <p>And this is my Custom Action:</p> <pre><code>extern "C" UINT __stdcall GetDatascanPort(MSIHANDLE hInstall) { HRESULT hr = S_OK; UINT er = ERROR_SUCCESS; HKEY keyHandle; DWORD i,openStatus,cb_value_buffer,cb_buffer,dwType; char value_buffer[100],buffer[10]; MSIHANDLE hTable = NULL; MSIHANDLE hColumns = NULL; MSIDBERROR insertError = MSIDBERROR_NOERROR; hr = WcaInitialize(hInstall, "GetDatascanPort"); ExitOnFailure(hr, "Failed to initialize"); WcaLog(LOGMSG_STANDARD, "Initialized."); if (RegCreateKeyEx( HKEY_LOCAL_MACHINE, "HARDWARE\\DEVICEMAP\\SERIALCOMM", 0, "", REG_OPTION_NON_VOLATILE, KEY_QUERY_VALUE, default_sa(), &amp;keyHandle, &amp;openStatus ) == ERROR_SUCCESS ) { for (i=0;;i++) { cb_value_buffer = sizeof(value_buffer); cb_buffer = sizeof(buffer); if (RegEnumValue(keyHandle, i, value_buffer, &amp;cb_value_buffer, NULL, &amp;dwType, (unsigned char *) buffer, &amp;cb_buffer) != ERROR_SUCCESS) break; if (dwType != REG_SZ || strlen(buffer) &gt; 6) continue; hr = WcaAddTempRecord(&amp;hTable, &amp;hColumns, L"ListBox",&amp;insertError, 0, 4, L"COMPORT", 1, 0, buffer); ExitOnFailure(hr, "failed to set COMPORT"); } RegCloseKey(keyHandle); if (hTable) MsiCloseHandle(hTable); if (hColumns) MsiCloseHandle(hColumns); return WcaFinalize(hr); } LExit: er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; return WcaFinalize(er); } </code></pre> <p>Can anyone help me please? Thanks</p> <p>EDIT: I have it updating my Listbox but it is not legible, strange symbols. I changed my char to a CString like so and this seems to work apart from displaying it incorrectly.</p> <pre><code>CString ComPort; ComPort = buffer; hr = WcaAddTempRecord(&amp;hTable, &amp;hColumns, L"ListBox",&amp;insertError, 0, 4, L"COMPORT", 1, ComPort, ComPort); ExitOnFailure(hr, "failed to set COMPORT"); </code></pre> <p>Also the target computer may have serial ports what is the best method to have them all listed with my function inside the for loop?</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload