Home > Back-end >  For help: run directly by VS Release is normal, but the double-click the generated exe program will
For help: run directly by VS Release is normal, but the double-click the generated exe program will

Time:10-20

Development environment for VS2013, the operating system is Win10 home edition, in VS, configuration in Release mode, run directly, the program can run normally, but double click the Release of the generated exe files, there will be a great probability (but not always) program will be stuck after running some code, and then flash back, without any error message, the location of the program to flash back also is not fixed, the Debug run directly generated exe file does not appear the phenomenon, can run normally, view the online method, if the Release of the generated exe program set to compatible mode (Windows 7 or doing), also won't appear the problem of flash back, but set the compatibility mode is not a perfect solution,
Could you tell me who know have what is the root cause of the phenomenon? Can thoroughly solve the problem?
Note: the code in the Chinese comments have been deleted, basic rule out for encoding causes part of the code did not compile,

CodePudding user response:

I variable function in Chinese software is full of Chinese haven't found a run-time error to exit the situation,

CodePudding user response:

Increase the log function
Position the error

CodePudding user response:

By looking at the system logs, display error module name is NTDLL. DLL, exception code 0 xc0000374

CodePudding user response:

Seems to be, and array or memory related
Visual studio call when there are some protective measures, run directly when losing the support of the debugging environment and the


Use the dump file, to find it

CodePudding user response:

Lead to found the error code, name of program to load uncertainty of DLL, defines a LPCWSTR variables of type, initialized to NULL, the value obtained by a string of a string, before from the Internet to find a string into LPCWSTR function,
 
LPCWSTR stringToLPCWSTR (STD: : string orig)
{
Size_t origsize=orig. Length () + 1;
Const size_t newsize=100;
Size_t convertedChars=0;
Would be * wcstring=(*) would be malloc (sizeof (would) * (orig. The length () - 1));
Mbstowcs_s (& amp; ConvertedChars wcstring, origsize, orig. C_str (), _TRUNCATE);

Return wcstring;
}

Call this function, you will be presented with a certain probability error, phenomenon as stated earlier, will call this function code is commented out, run directly Release generated exe, no flash back phenomenon, but didn't see specific reason, which give advice?

Part of the code:
 
LPCWSTR lpcDllName=NULL;
String STR="XXXXXXXX";
LpcDllName=StringToLPCWSTR (STR);//application error caused by this statement
HMODULE h=LoadLibrary (lpcDllName);

CodePudding user response:

Would be * wcstring=(*) would be malloc (sizeof (would) * (orig. The length () - 1));

Be + 1

CodePudding user response:

Size_t origsize=orig. Length () + 1;
Const size_t newsize=100;
Size_t convertedChars=0;
Would be * wcstring=(*) would be malloc (sizeof (would) * (orig. The length () - 1));
Mbstowcs_s (& amp; ConvertedChars wcstring, origsize, orig. C_str (), _TRUNCATE);

Return wcstring;

CodePudding user response:

Indeed, to + 1 is a step in the right, thank you upstairs!
This is another way of transformation, if not found the problem, he is a + 1,
 
String image_path="c: \ \ avi PNG";
Size_t size=image_path. Length ();
Would be * buffer=new would [size + 1];
MultiByteToWideChar (CP_ACP, 0, the response - & gt; Image_path. C_str (), the size, buffer, size * sizeof (would));
Buffer [size]=0;//ensure that ends in '\ 0'
: : MessageBox (NULL, buffer, NULL, NULL);
Delete buffer;
Buffer=null;

CodePudding user response:

To wonder whether the 1 you input code input wrong
Or the original author to dig a pit, special packing you this copy and paste is not you want to do,

CodePudding user response:

Online copy problem much more code to have the pit real
Most of them are belong to the model code, does not have its own tested, copycat aren't readily available

CodePudding user response:

Is copied from here
https://www.cnblogs.com/tsh292278/p/10522931.html

CodePudding user response:

This problem really hidden, run directly in the VS normal, normal run directly in the Debug, Release exe with compatibility mode in normal operation, is the most headache is the problem of random, not only whether the random error, and even the location of the error is random, uncertainty in the process of start program will run where flash back, even if the normal boot, program exit is also wrong

CodePudding user response:

MByte of Windows and Unicode (2 bytes) is pit dad, tchar, make a pile of _T in h (), do not set the code page also complains that the machine makes a lot of quality API has two versions, a char *, a wchar *, and then external use macros uniform interface, come up with a pile of LPCTSTR, C/C + + this is reputation was ruined,

Investigate its reason, or because Windows appear early, Windows 3.1, support for internationalization is still very imperfect, utf-8, etc. The ultimate solution is not yet mature, then for the sake of backward compatibility, step by step to become like this now, Linux appeared late, now if you use Windows Linux environment, or a third party such as msys2 API, all is utf-8, do not have this problem, under the native Linux is no problem,

Now my ultimate solution is to use msys2 Qt, and Qt seers, all use utf-8 is no problem, Qt + VC more pit dad, if the character type of the source code does not match, interface button is stil in Chinese,

CodePudding user response:

Why there are soft narrow expand health is not good to use this function
  • Related