<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ShellExecute bug with niFgen in Signal Generators</title>
    <link>https://ni.lithium.com/t5/Signal-Generators/ShellExecute-bug-with-niFgen/m-p/487313#M830</link>
    <description>&lt;DIV&gt;&lt;/DIV&gt;By the way, I apologize for the spelling errors - I hit the _submit post_ button a little sooner that I intended. At this moment there is not much _senior software engineer_ about me.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 06 Mar 2007 16:51:07 GMT</pubDate>
    <dc:creator>sead_suskic</dc:creator>
    <dc:date>2007-03-06T16:51:07Z</dc:date>
    <item>
      <title>ShellExecute bug with niFgen</title>
      <link>https://ni.lithium.com/t5/Signal-Generators/ShellExecute-bug-with-niFgen/m-p/486805#M827</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;I have a problem with niFgen version 2.4.0.49153.&lt;BR /&gt;&lt;BR /&gt;If I call niFgen_init() or niFgen_InitWithOptions(), then I cannot call ShellExecute successfully!&lt;BR /&gt;&lt;BR /&gt;Lets say I call&lt;BR /&gt;&lt;BR /&gt;ShellExecute(NULL, "open", "http://www.google.com", NULL, NULL, SW_SHOWNORMAL);&lt;BR /&gt;&lt;BR /&gt;I get the error message &lt;SPAN class="clsLiteral"&gt;SE_ERR_ACCESSDENIED.&lt;BR /&gt;&lt;BR /&gt;If however I never call &lt;/SPAN&gt;niFgen_init(), then the ShellExecute call is completed successfully...&lt;BR /&gt;&lt;BR /&gt;Does anyone know how to fix this issue?&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 05 Mar 2007 21:04:30 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/Signal-Generators/ShellExecute-bug-with-niFgen/m-p/486805#M827</guid>
      <dc:creator>ElGrimo</dc:creator>
      <dc:date>2007-03-05T21:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: ShellExecute bug with niFgen</title>
      <link>https://ni.lithium.com/t5/Signal-Generators/ShellExecute-bug-with-niFgen/m-p/487287#M828</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;Calling CoInitialize(NULL) before the call to niFgen_init()&amp;nbsp; will solve the problem. &lt;/P&gt;&lt;FONT face="Helv" size="2"&gt;
&lt;P&gt;The issue is caused by the fact that the niFgen uses the IVI Configuration Server C API which is a C wrapper over a COM component. By default, the C API initializes COM for every thread in MTA (apartment) mode. It appears that ShellExecute attempts to initialize COM in STA mode (which will fail) but it does not check to see if the thread has already been initialized with a different threading model and take appropriate action. We will&amp;nbsp;report this&amp;nbsp;bug to Microsoft.&lt;/P&gt;
&lt;P&gt;Best regards.&lt;/P&gt;&lt;/FONT&gt;</description>
      <pubDate>Tue, 06 Mar 2007 16:10:26 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/Signal-Generators/ShellExecute-bug-with-niFgen/m-p/487287#M828</guid>
      <dc:creator>z_haider</dc:creator>
      <dc:date>2007-03-06T16:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: ShellExecute bug with niFgen</title>
      <link>https://ni.lithium.com/t5/Signal-Generators/ShellExecute-bug-with-niFgen/m-p/487301#M829</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;ElGrimo,&lt;BR /&gt;&lt;BR /&gt;It turns out that the encountered behavior is not really a bug - if it was one, it could be from the point to view of inadequate documentation, but&amp;nbsp; once you hear the issue details you just might agree with me that it's not the most easily documentable thing until you come across it.&lt;BR /&gt;&lt;BR /&gt;From what I was able to see with the debugger and Windows symbols, it appears that the ShellExecute() implementation goes through a COM mechanism resulting in an invokation of a CoInitialize() looking-like function. Additionally, NI-Fgen driver is an IVI driver and through the IVI Engine uses the IVI Configuration Store - a COM component - through its C API. From what my colleagues in the IVI group tell me, it appears that these two COM components have different threading models which can cause one not to load if the other one loads first. To illustrate in more details what is going on with resepct to invocation of CoInitialize(), please see &lt;A href="http://blogs.msdn.com/larryosterman/archive/2004/05/12/130541.aspx" target="_blank"&gt;this posting.&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;There is a work-around in this case. Your application could call CoInitialize(NULL) for each thread (if there are more than one) before calling any of the NI-Fgen functions. This will initialize the threads in the appropriate mode that would work both for the shell and the IVI components.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;Regards,</description>
      <pubDate>Tue, 06 Mar 2007 16:30:55 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/Signal-Generators/ShellExecute-bug-with-niFgen/m-p/487301#M829</guid>
      <dc:creator>sead_suskic</dc:creator>
      <dc:date>2007-03-06T16:30:55Z</dc:date>
    </item>
    <item>
      <title>Re: ShellExecute bug with niFgen</title>
      <link>https://ni.lithium.com/t5/Signal-Generators/ShellExecute-bug-with-niFgen/m-p/487313#M830</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;By the way, I apologize for the spelling errors - I hit the _submit post_ button a little sooner that I intended. At this moment there is not much _senior software engineer_ about me.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 06 Mar 2007 16:51:07 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/Signal-Generators/ShellExecute-bug-with-niFgen/m-p/487313#M830</guid>
      <dc:creator>sead_suskic</dc:creator>
      <dc:date>2007-03-06T16:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: ShellExecute bug with niFgen</title>
      <link>https://ni.lithium.com/t5/Signal-Generators/ShellExecute-bug-with-niFgen/m-p/487374#M831</link>
      <description>Thanks everyone for the solution and technical details!&lt;BR /&gt;&lt;BR /&gt;I am now calling CoInitialize before initializing the signal generator, and everything is fine.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 06 Mar 2007 18:34:53 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/Signal-Generators/ShellExecute-bug-with-niFgen/m-p/487374#M831</guid>
      <dc:creator>ElGrimo</dc:creator>
      <dc:date>2007-03-06T18:34:53Z</dc:date>
    </item>
  </channel>
</rss>

