I have been trying both ShellExecute and CreateProcess to Launch a game - My goal is to hide the game window. The game is built using DirectX9. For some reason I am struggling on this issue. I am using the following codes independently but without success
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = app_exe; // Path to game
ShExecInfo.lpParameters = "";
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_HIDE;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
And with CreateProcess
ZeroMemory(&procInfo, sizeof(PROCESS_INFORMATION));
ZeroMemory(&startupInfo, sizeof(STARTUPINFO));
startupInfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
startupInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
startupInfo.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
startupInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE);
startupInfo.wShowWindow = SW_HIDE;
CreateProcess(app_exe, cmdline, NULL, NULL, FALSE,CREATE_NO_WINDOW , NULL, NULL,&startupInfo, &procInfo);
WaitForSingleObject(procInfo.hProcess, INFINITE);
In both cases the game is launched and I get a full-screen game.
Is there anything wrong that I am doing?
The STARTUPINFO.wShowWindow flag ends up in WinMain as the final parameter nCmdShow (https://msdn.microsoft.com/en-us/library/windows/desktop/ff381406(v=vs.85).aspx). There is no requirement that the created process adheres to this request. It is free to create as many visible windows as it likes. In fact, it's commonplace to completely ignore this flag. If you have the source code to the application being launched, and can recompile it, you could make it respect this request.
Also, I haven't tried it, but I would think that attempting to hide a DirectX fullscreen window will likely fail, and/or cause issues.
Related
if (this.PendingLocalUARTCreditsCount != 0) return;
this.PendingLocalUARTCreditsCount = this.MaxLocalUARTCreditsCount - this.LocalUARTCreditsCount;
IntPtr value = (IntPtr)(this.PendingLocalUARTCreditsCount);
NSData valueData = NSData.FromBytes(value, 1);
this.CbPeripheral.WriteValue(valueData, this.UartRxCreditsCharacteristic, CBCharacteristicWriteType.WithoutResponse);
Got stacktrace error with NSData valueData = NSData.FromBytes(value, 1);
I haven't solved it though in any way. I am developing in C# for an ipad app project using vs 2019 and a, Mac
Nick
Native Crash Reporting
=================================================================
Got a SIGSEGV while executing native code. This usually indicates a fatal error in the mono runtime or one of the native libraries used by your application.
=================================================================
I got SIGSEGV error not SIGABRT. I can discover connect and disconnect but not set rx credits on the peripheral (using Telit 4.0 Bluetooth low, energy module) and am trying to get communication to work so don't think have to set Bluetooth permissions The problem I think is the pointer (Intpr) pointing to the wrong address as app crashes, when it deferences the data.
Thanks for the input though.
Regards nick
Welcome to SO ! You'd better update content all in question , then other people will know problem more clearly .
Although not knowing why NSData.FromBytes occurs error , however there is a workaround for you to check . Using NSData.FromArrayto transfer int to NSData .
int valueInt = 1234567890;
Byte[] byteData = new Byte[1];
byteData[0] = (Byte)((valueInt & 0xFF));
Console.WriteLine("-----NSData-------" + NSData.FromArray(byteData));
Then output is :
-----NSData-------{length = 1, bytes = 0xd2}
Therefore , shared code can be modified as follow :
...
Byte[] byteData = new Byte[1];
byteData[0] = (Byte)((this.PendingLocalUARTCreditsCount & 0xFF));
NSData valueData = NSData.FromArray(byteData);
...
I'm developing an application from which I want to send EMail. When I click button/menu Outlook Sendmail window displays properly.
When I open Address Book, the dialog displays properly but the title of the dialog dispalys only "S".
Actually that title has to be displayed as " Selected Names: ... ".
Code:
HWND hWnd = this->GetSafeHwnd();
MAPIINIT_0 tMapInit = { 0, MAPI_MULTITHREAD_NOTIFICATIONS };
HRESULT hResult = MAPIInitialize( &tMapInit );
HMODULE hMapiMod = LoadLibrary(_T("mapi32.dll"));
ProcMapiLogon = (LPMAPILOGON)GetProcAddress( hMapiMod, "MAPILogon" );
(ProcMapiLogon)( (ULONG)hWnd, NULL, NULL, MAPI_LOGON_UI | MAPI_NEW_SESSION, 0, &hCurrentSession );
LPMAPISENDMAIL ProcMapiSendMail = NULL;
ProcMapiSendMail = (LPMAPISENDMAIL)GetProcAddress(hMapiMod, "MAPISendMail");
(ProcMapiSendMail)(hCurrentSession, (ULONG)hWnd, &myMsg, MAPI_DIALOG | MAPI_LOGON_UI, 0);
Note: This applicaion is build in command prompt with unicode flag _UNICODE set and the compiler is Visual Studio 2008.
Kindly help me to fix the problem.
Thanks in Advance.
Simple MAPI functions only work with ANSI strings. Also keep in mind that it is never a good idea to rely on conditional compile when interfacing with Simple or Extended MAPI. Always specify the string flavor (ANSI vs wide string) explicitly in your code.
I have a very simple ExtendScript script which creates a new document out of a subset of the current active document:
var sourceDocument = app.activeDocument;
var i, j;
for(i = 0; i < sourceDocument.layers.length; i++) {
sourceDocument.layers.item(i).locked = false;
}
for(i = 0; i < sourceDocument.spreads.length; i++) {
for(j = 0; j < sourceDocument.spreads.item(i).textFrames.length; j++) {
if(sourceDocument.spreads.item(i).textFrames.item(j).locked) {
sourceDocument.spreads.item(i).textFrames.item(j).locked = false;
}
}
}
var destDocument = app.documents.add();
var firstPageIndex = 0; // In the actual script, this is chosen by the user.
var lastPageIndex = 5; // In the actual script, this is chosen by the user.
destDocument.importStyles(ImportFormat.paragraphStylesFormat, new File(sourceDocument.filePath + "/" + sourceDocument.name), GlobalClashResolutionStrategy.LOAD_ALL_WITH_OVERWRITE);
destDocument.importStyles(ImportFormat.characterStylesFormat, new File(sourceDocument.filePath + "/" + sourceDocument.name), GlobalClashResolutionStrategy.LOAD_ALL_WITH_OVERWRITE);
destDocument.viewPreferences.horizontalMeasurementUnits = sourceDocument.viewPreferences.horizontalMeasurementUnits;
destDocument.viewPreferences.verticalMeasurementUnits = sourceDocument.viewPreferences.verticalMeasurementUnits;
destDocument.documentPreferences.facingPages = sourceDocument.documentPreferences.facingPages;
destDocument.documentPreferences.pageHeight = sourceDocument.documentPreferences.pageHeight;
destDocument.documentPreferences.pageWidth = sourceDocument.documentPreferences.pageWidth;
destDocument.documentPreferences.pageSize = sourceDocument.documentPreferences.pageSize;
destDocument.documentPreferences.allowPageShuffle = true;
var range = sourceDocument.pages.itemByRange(firstPageIndex, lastPageIndex);
range.duplicate(LocationOptions.AFTER, destDocument.pages[destDocument.pages.length - 1]);
destDocument.pages[0].remove(); // An empty spread containing an empty page is added when the new document is created and we cannot remove it before other pages are inserted (Documents must have at least one page)
This script works perfectly on many documents. But when I execute it against one particular document (let's call it foo.indd), InDesign becomes unresponsive when executing the duplication: range.duplicate(LocationOptions.AFTER, destDocument.pages[destDocument.pages.length - 1]);. From then on, the only thing I can do is force InDesign to quit.
Is this an InDesign bug? How can I find which part of this particular document is creating the problem?
I can't really say what's wrong in your example but if indesign hangs, that might caused by the loops ( to infinity and beyond :) )
So you may try to avoid issues by outputting the loop limit to avoid InDesign re-calculation
var limit = …
for ( i = 0; i<limit ; i++)…
Additionally you could try to write info on the console to get info where InDesign is actually being stuck. So write informations on the fly on a report file and you might finally identify the issue area.
Also, you can try to interrogate every key items to see if the file has some issue.
Last but not least, try a manual export to idml of this file, re open and run again the script. Sometimes files become clunky and passing by idml fix most of them.
Give this script a try onto your probleamtic file. If it fails, please have a look at the report it should have generated onto the desktop.
http://www.loicaigon.com/downloads/cloneDocument.jsx
Loic
http://www.loicaigon.com
I am trying to copy file into the setup target directory.
I am using this:
TCHAR destPath[ MAX_PATH ] = &L"[TARGETDIR]";
wcscat_s(destPath, L"LiveFo#nextjmp.com\\Capture.png");
CopyFile(L"C:\\Users\\waldek\\Desktop\\Capture.png", destPath, 0);
if I use this:
CopyFile(L"C:\\Users\\waldek\\Desktop\\Capture.png", L"C:\\Program Files (x86)\\Microsoft\\Setup1\\LiveFo#nextjmp.com\\Capture.png", 0);
it works, which is basically what destPath should evaluate to, I can see that it evaluates when I use PMSIHANDLE, it alerts the correct path...
How do I force CopyFile to evalue "[TARGETDIR]";
WCHAR vbuff [MAX_PATH] = {0};
DWORD vlen = MAX_PATH;
UINT gp = MsiGetPropertyW(hInstall, L"CustomActionData", vbuff, &vlen);
in the Install Custom Action in property CustomactionData, I just put [TARGETDIR]
vbuff is the target directory
then of course the concatenation and the FileCopy executed as expected...
this worked for me... but I still would like to know why, it didn't in the original question I posted, the strangest thing was that the PMSIHANDLE wrote out the correct path, but I guess there "translation" step was missing in passing it in the FileCopy function...
I am sure I am missing some theory on this.
Assuming this is part of a custom action, you can use MsiFormatRecord. Error handling omitted, it would look something like this:
PMSIHANDLE hRec = MsiCreateRecord(1);
MsiRecordSetString(hRec, 0, _T("[TARGETDIR]LiveFo#nextjmp.com"));
TCHAR szPath[MAX_PATH] = {0};
DWORD cchPath = MAX_PATH;
MsiFormatRecord(hInstall, hRec, szPath, &cchPath);
In my winforms app interacting with Excel through the com interop,
I'm trying to attach to an existing Excel process if there is one. Getting the object seems to work well, but if the Excel application is minimized (which is quite likely in my use case), I don't manage to restore the window and bring it to the front.
I've tried the following statements:
try
app = (Excel.Application)Marshal.GetActiveObject("Excel.Application");
catch (Exception) { /* ignore */ }
if (app == null)
{
app = new Excel.Application();
app.Visible = true;
}
if (app.ActiveWindow.WindowState == Excel.XlWindowState.xlMinimized)
app.ActiveWindow.WindowState = Excel.XlWindowState.xlNormal;
wb = ...
wb.Activate();
None of these had any effect. How can I achieve that?
(Please Note: My problem relates to the case when there is an existing instance, so the "Visible = true" is not necessary and this thread does not apply.)
You want app.WindowState = xlNormal as app.ActiveWindow is the current sheet not the application instances main window.