{"id":1453,"date":"2014-03-20T07:00:00","date_gmt":"2014-03-20T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2014\/03\/20\/going-for-the-facts-who-is-displaying-this-message-box\/"},"modified":"2014-03-20T07:00:00","modified_gmt":"2014-03-20T07:00:00","slug":"going-for-the-facts-who-is-displaying-this-message-box","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20140320-00\/?p=1453","title":{"rendered":"Going for the facts: Who is displaying this message box?"},"content":{"rendered":"<p>\nA customer wanted to know whether\n<code>Create&shy;Process<\/code> had a problem with Unicode.\n<\/p>\n<p>\nA problem with it?\nQuite the contrary.\n<code>Create&shy;Process<\/code> <i>loves<\/i> Unicode!\nIn fact, if you call the ANSI version, it converts the\nstrings to Unicode and then finishes the work in Unicode.\n<\/p>\n<p>\nOkay, here&#8217;s the customer&#8217;s problem.\n<\/p>\n<blockquote CLASS=\"q\">\n<p>\nWe have a custom application written in managed code.\nWhen we launch the process from unmanaged code via\n<code>Create&shy;Process<\/code>,\nwe sometimes get a bogus error message:\n<\/p>\n<blockquote CLASS=\"m\"><p>\nWARNING!\nThe specified path, file name, or both are too long.\nThe fully qualified file name must be less than 260 characters,\nand the directory name must be less than 248 characters.\n<\/p><\/blockquote>\n<p>\nThe filename is well under the 260-character limit\nand the directory name is well under the 248-character limit.\nWe have isolated the problem to be related to whether we\nput Unicode characters in the command line arguments.\nIf the command line arguments are all ASCII,\nthen no message appears.\n<\/p>\n<p>\nIn case it matters, here&#8217;s our code to launch the custom\napplication.\n<\/p>\n<pre>\nSTARTUP_INFO si = { sizeof(si) };\nPROCESS_INFORMATION pi;\nif (CreateProcess(NULL, commandLine, 0, 0, FALSE,\n                   NORMAL_PRIORITY_CLASS, 0, 0,\n                   &amp;si, &amp;pi)  ...\n \/\/ (in our case, the call succeeds)\n<\/pre>\n<p>\nWhat do we have to do to get\n<code>Create&shy;Process<\/code> to accept\nnon-ASCII characters on the command line\nwithout display an error message?\n<\/p>\n<\/blockquote>\n<p>\n(Note that Unicode is a superset of ASCII.\nAll ASCII characters are also Unicode characters.\nThe customer is making the common mistake of saying\nUnicode when they mean Unicode-not-ASCII.)\n<\/p>\n<p>\nActually, that error message is not coming from\n<code>Create&shy;Process<\/code>.\nIt&#8217;s coming from the custom application.\n<\/p>\n<blockquote CLASS=\"q\"><p>\nWe have the source code for our custom application\nand it does not display this message.\nThe custom application actually\nreceives the command line just fine (be it Unicode or not),\nbut if there is Unicode in the command line,\nwe get the message above.\n<\/p><\/blockquote>\n<p>\nThe message box may not be coming from your code,\nbut it&#8217;s still coming from your application.\nWhy not hook up a debugger when the message box is up,\nthen\n<a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2008\/07\/23\/8765362.aspx\">\ntake a stack trace to see whose idea it was to display\nthe message box<\/a>.\n<\/p>\n<p>\nThe customer connected a debugger and determined that\nthe message was coming from a third-party library that their\ncustom application uses.\nNow they know whom to talk to in order to solve the problem.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A customer wanted to know whether Create&shy;Process had a problem with Unicode. A problem with it? Quite the contrary. Create&shy;Process loves Unicode! In fact, if you call the ANSI version, it converts the strings to Unicode and then finishes the work in Unicode. Okay, here&#8217;s the customer&#8217;s problem. We have a custom application written in [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-1453","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>A customer wanted to know whether Create&shy;Process had a problem with Unicode. A problem with it? Quite the contrary. Create&shy;Process loves Unicode! In fact, if you call the ANSI version, it converts the strings to Unicode and then finishes the work in Unicode. Okay, here&#8217;s the customer&#8217;s problem. We have a custom application written in [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/1453","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=1453"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/1453\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=1453"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=1453"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=1453"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}