Example #1
0
STDMETHODIMP CDummyConsumer::BackgroundExecute(BSTR filename)
{
	_bstr_t testFilename(filename);

	MetawallBackEnd::IMWHostInstanceManagerPtr spWordController;
	HRESULT hr = spWordController.CreateInstance(L"WordInstanceManager.Controller");
	if(FAILED(hr))
		return hr;

	// Force initialization of the message filter on the foreground thread.
	IDispatchPtr spDispatch = spWordController->OpenDocument(testFilename, true);
	spWordController->CloseDocument(spDispatch, vtMissing);

	// Initialization of the message filter is not supported for background threads.
	// The background thread will cause an addref on the foreground threads controller 
	// whe ExecuteStrategy is called.
	BackgroundRunner backgroundRunner(testFilename);
	backgroundRunner.WaitForThread();
	DWORD exitCode = backgroundRunner.GetExitCode();
	return (exitCode == 0xffffffff ? S_OK : exitCode);
}
Example #2
0
int main(int argc, char ** argv) {
	testFilename("TEST.TXT", 0);
	testFilename("12345678.910", 0);
	testFilename("1234567.890", 0);
	testFilename("Hello.c", 0);
	testFilename("VERYLONGF.ILE", 0);
	testFilename("this2longnames", 986);
	testFilename("verylongfile.name", 1233);
	testFilename("TEST.1234", 0);
	testFilename("TEXT.TMP.TXT", 0);
	testFilename("TEXTTMP.TXT", 0);
	testFilename("foobarfoobarfoo.bar", 0);
}