本文整理匯總了C++中CoUninitialize函數的典型用法代碼示例。如果您正苦於以下問題:C++ CoUninitialize函數的具體用法?C++ CoUninitialize怎麽用?C++ CoUninitialize使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CoUninitialize函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: main
//.........這裏部分代碼省略.........
//Allocate Memory
categories = (long *)calloc (numberOfCategories , sizeof(long));
BAIL_ON_ALLOC_FAILURE(categories, calloc);
//Take Firewall Category Ownership
categories[0] = NET_FW_RULE_CATEGORY_FIREWALL;
result = ArrayOfLongsToVariant(numberOfCategories, categories, &varCategories);
displayName = SysAllocString(L"@RegisterFirewallSample.exe,-127");
BAIL_ON_ALLOC_FAILURE(displayName, SysAllocString);
hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
if (FAILED(hr))
{
//COM initialize failed
wprintf(L"CoInitialize failed: 0x%08lx\n", result);
goto CLEANUP;
}
comInit = TRUE;
hr = CoCreateInstance(__uuidof(NetFwProduct),NULL,CLSCTX_INPROC_SERVER,__uuidof(INetFwProduct),(void**)&product );
if (FAILED(hr))
{
//CoCreateInstance Failed
wprintf(L"CoCreateInstance for INetFwProduct failed: 0x%08lx\n", hr);
goto CLEANUP;
}
hr = product->put_DisplayName(displayName);
if (FAILED(hr))
{
//Put_displayName failed
wprintf(L"put_DisplayName for INetFwProduct failed Error: 0x%08lx\n", hr);
goto CLEANUP;
}
hr = product->put_RuleCategories(varCategories);
if (FAILED(hr))
{
//Put_rulecategories failed
wprintf(L"put_RuleCategories failed for INetFwProduct Error: 0x%08lx\n", hr);
goto CLEANUP;
}
hr = CoCreateInstance(__uuidof(NetFwProducts),NULL,CLSCTX_INPROC_SERVER,__uuidof(INetFwProducts),(void**)&products );
if (FAILED(hr))
{
//CoCreateInstance Failed
wprintf(L"CoCreateInstance for INetFwProducts failed: 0x%08lx\n", hr);
goto CLEANUP;
}
hr = products->Register(product, ®istration);
if (FAILED(hr))
{
//Failed to Register Products
wprintf(L"Register failed: 0x%08lx\n", hr);
goto CLEANUP;
}
hr = products->get_Count( &count);
if (FAILED(hr))
{
//Failed to get Count of Products
wprintf(L"Get count failed: 0x%08lx\n", hr);
goto CLEANUP;
}
wprintf(L"INetFwProducts_Count returned %ld.\n", count);
wprintf(L"Hit any key to unregister.\n");
_getch();
CLEANUP:
if (registration != NULL)
{
registration->Release();
}
if (products != NULL)
{
products->Release();
}
if (product != NULL)
{
product->Release();
}
if (comInit)
{
CoUninitialize();
}
free(categories);
SysFreeString(displayName);
VariantClear(&varCategories);
return;
}
示例2: MOZ_ASSERT
void
WMFDecoderModule::OnDecodeThreadFinish()
{
MOZ_ASSERT(!NS_IsMainThread(), "Must be on main thread.");
CoUninitialize();
}
示例3: MCIQTZ_mciOpen
//.........這裏部分代碼省略.........
hr = IGraphBuilder_QueryInterface(wma->pgraph, &IID_IMediaSeeking, (void**)&wma->seek);
if (FAILED(hr)) {
TRACE("Cannot get IMediaSeeking interface (hr = %x)\n", hr);
goto err;
}
hr = IGraphBuilder_QueryInterface(wma->pgraph, &IID_IMediaEvent, (void**)&wma->mevent);
if (FAILED(hr)) {
TRACE("Cannot get IMediaEvent interface (hr = %x)\n", hr);
goto err;
}
hr = IGraphBuilder_QueryInterface(wma->pgraph, &IID_IVideoWindow, (void**)&wma->vidwin);
if (FAILED(hr)) {
TRACE("Cannot get IVideoWindow interface (hr = %x)\n", hr);
goto err;
}
hr = IGraphBuilder_QueryInterface(wma->pgraph, &IID_IBasicVideo, (void**)&wma->vidbasic);
if (FAILED(hr)) {
TRACE("Cannot get IBasicVideo interface (hr = %x)\n", hr);
goto err;
}
hr = IGraphBuilder_QueryInterface(wma->pgraph, &IID_IBasicAudio, (void**)&wma->audio);
if (FAILED(hr)) {
TRACE("Cannot get IBasicAudio interface (hr = %x)\n", hr);
goto err;
}
if (!(dwFlags & MCI_OPEN_ELEMENT) || (dwFlags & MCI_OPEN_ELEMENT_ID)) {
TRACE("Wrong dwFlags %x\n", dwFlags);
goto err;
}
if (!lpOpenParms->lpstrElementName || !lpOpenParms->lpstrElementName[0]) {
TRACE("Invalid filename specified\n");
goto err;
}
TRACE("Open file %s\n", debugstr_w(lpOpenParms->lpstrElementName));
hr = IGraphBuilder_RenderFile(wma->pgraph, lpOpenParms->lpstrElementName, NULL);
if (FAILED(hr)) {
TRACE("Cannot render file (hr = %x)\n", hr);
goto err;
}
IVideoWindow_put_AutoShow(wma->vidwin, OAFALSE);
IVideoWindow_put_Visible(wma->vidwin, OAFALSE);
if (dwFlags & MCI_DGV_OPEN_WS)
style = lpOpenParms->dwStyle;
if (dwFlags & MCI_DGV_OPEN_PARENT) {
IVideoWindow_put_MessageDrain(wma->vidwin, (OAHWND)lpOpenParms->hWndParent);
IVideoWindow_put_WindowState(wma->vidwin, SW_HIDE);
IVideoWindow_put_WindowStyle(wma->vidwin, style|WS_CHILD);
IVideoWindow_put_Owner(wma->vidwin, (OAHWND)lpOpenParms->hWndParent);
GetClientRect(lpOpenParms->hWndParent, &rc);
IVideoWindow_SetWindowPosition(wma->vidwin, rc.left, rc.top, rc.right - rc.top, rc.bottom - rc.top);
wma->parent = (HWND)lpOpenParms->hWndParent;
}
else if (style)
IVideoWindow_put_WindowStyle(wma->vidwin, style);
IBasicVideo_GetVideoSize(wma->vidbasic, &rc.right, &rc.bottom);
wma->opened = TRUE;
if (dwFlags & MCI_NOTIFY)
mciDriverNotify(HWND_32(LOWORD(lpOpenParms->dwCallback)), wDevID, MCI_NOTIFY_SUCCESSFUL);
return 0;
err:
if (wma->audio)
IBasicAudio_Release(wma->audio);
wma->audio = NULL;
if (wma->vidbasic)
IBasicVideo_Release(wma->vidbasic);
wma->vidbasic = NULL;
if (wma->seek)
IMediaSeeking_Release(wma->seek);
wma->seek = NULL;
if (wma->vidwin)
IVideoWindow_Release(wma->vidwin);
wma->vidwin = NULL;
if (wma->pgraph)
IGraphBuilder_Release(wma->pgraph);
wma->pgraph = NULL;
if (wma->mevent)
IMediaEvent_Release(wma->mevent);
wma->mevent = NULL;
if (wma->pmctrl)
IMediaControl_Release(wma->pmctrl);
wma->pmctrl = NULL;
if (wma->uninit)
CoUninitialize();
wma->uninit = FALSE;
return MCIERR_INTERNAL;
}
示例4: UnCOM
static void UnCOM (void)
{
CoUninitialize ();
}
示例5: main
int main(int argc, char* argv[])
{
IGraphBuilder *pGraph = NULL;
ICaptureGraphBuilder2 *pBuilder = NULL;
IBaseFilter *pSrc = NULL;
IBaseFilter *ppf = NULL;
IFileSinkFilter *pSink = NULL;
IMediaControl *pMC = NULL;
HRESULT hr;
CoInitialize (NULL);
// Create the filter graph.
CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC,
IID_IGraphBuilder, (void **)&pGraph);
// Create the capture graph builder.
CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC,
IID_ICaptureGraphBuilder2, (void **)&pBuilder);
pBuilder->SetFiltergraph(pGraph);
pSrc=GetAudioDevice ();
// add the first audio filter in the list
pGraph->AddFilter(pSrc, L"Video Capture");
/* pBuilder->SetOutputFileName(
&MEDIASUBTYPE_Avi,
L"C:\\Example.avi",
&ppf,
&pSink);*/
// pBuilder->AllocCapFile (L"C:\\temp.avi", _MAX_PATH);
pBuilder->RenderStream(
&PIN_CATEGORY_CAPTURE, // Pin category
&MEDIATYPE_Audio, // Media type
pSrc, // Capture filter
NULL, // Compression filter (optional)
ppf // Multiplexer or renderer filter
);
REFERENCE_TIME rtStart = 20000000,
rtStop = 50000000;
/* pBuilder->ControlStream(
&PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Audio,
pSrc, // Source filter
&rtStart, // Start time
&rtStop, // Stop time
0, // Start cookie
0 // Stop cookie
);*/
pGraph->QueryInterface (IID_IMediaControl, (void **) &pMC);
pMC->Run ();
MessageBox (NULL, "Stop Recording", NULL, NULL);
pMC->Stop ();
/* CProgress *pProg = new CProgress(TEXT(""), NULL, &hr);
IAMCopyCaptureFileProgress *pIProg = NULL;
hr = pProg->QueryInterface(IID_IAMCopyCaptureFileProgress,
(void **)&pIProg);
//pBuilder->CopyCaptureFile (L"C:\\temp.avi", L"C:\\final.avi", TRUE, pIProg);*/
CoUninitialize ();
return 0;
}
示例6: main
//.........這裏部分代碼省略.........
if (!SUCCEEDED(hr) )
{
return hr;
}
VARIANT var;
// we omit checking result for brevity..
// First Name
VariantInit(&var);
V_BSTR(&var) = SysAllocString(L"Janet");
V_VT(&var) = VT_BSTR;
hr = pADs->Put( L"givenName", var );
// Last Name
VariantClear(&var);
V_BSTR(&var) = SysAllocString(L"Johns");
V_VT(&var) = VT_BSTR;
hr = pADs->Put( L"sn", var );
VariantClear(&var);
// Other Telephones
LPWSTR pszPhones[] = { L"425 844 1234", L"425 924 4321" };
DWORD dwNumber = sizeof( pszPhones ) /sizeof(LPWSTR);
hr = ADsBuildVarArrayStr( pszPhones, dwNumber, &var );
hr = pADs->Put( L"otherTelephone", var );
VariantClear(&var);
hr = pADs->SetInfo();
pADs->Release();
if (!SUCCEEDED(hr) )
{
return hr;
}
/////////////////////////////////////////////////
// Alternatively, you can use IDirectoryObject
//////////////////////////////////////////////////
IDirectoryObject *pDir=NULL;
hr = ADsGetObject(pszADsPath,
IID_IDirectoryObject,
(void**) &pDir );
if ( !SUCCEEDED(hr) )
{
return hr;
}
DWORD dwReturn;
ADSVALUE snValue;
ADSVALUE fNameValue;
ADSVALUE phoneValue[2];
ADS_ATTR_INFO attrInfo[] = {
{L"givenName",ADS_ATTR_UPDATE, ADSTYPE_CASE_IGNORE_STRING,&snValue,1},
{L"sn", ADS_ATTR_UPDATE, ADSTYPE_CASE_IGNORE_STRING,&fNameValue,1 },
{L"otherTelephone", ADS_ATTR_UPDATE, ADSTYPE_CASE_IGNORE_STRING, phoneValue,2 }
};
DWORD dwAttrs = sizeof(attrInfo)/sizeof(ADS_ATTR_INFO);
///// First Name ///////////
fNameValue.dwType=ADSTYPE_CASE_IGNORE_STRING;
fNameValue.CaseIgnoreString = L"Janet";
///// Last Name ///////////
snValue.dwType= ADSTYPE_CASE_IGNORE_STRING;
snValue.CaseIgnoreString = L"Johns";
///// Other Telephone ///////////
phoneValue[0].dwType = ADSTYPE_CASE_IGNORE_STRING;
phoneValue[0].CaseIgnoreString = L"425 844 1234";
phoneValue[1].dwType = ADSTYPE_CASE_IGNORE_STRING;
phoneValue[1].CaseIgnoreString = L"425 924 4321";
hr = pDir->SetObjectAttributes(attrInfo, dwAttrs, &dwReturn);
pDir->Release();
if ( !SUCCEEDED(hr) )
{
return hr;
}
CoUninitialize();
return 0;
}
示例7: PromptFileLocation
bool PromptFileLocation(std::wstring& resultPath, std::wstring title=L"Open", fileType filterType=ft_exe)
{
HRESULT hr;
hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
if (!SUCCEEDED(hr))
{
CoUninitialize();
return false;
}
IFileOpenDialog *pFileOpen;
// Create the FileOpenDialog object.
hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_ALL, IID_IFileOpenDialog, reinterpret_cast<void**>(&pFileOpen));
if (!SUCCEEDED(hr))
{
pFileOpen->Release();
CoUninitialize();
return false;
}
// Set the filter type
switch (filterType)
{
case ft_exe:
{
COMDLG_FILTERSPEC filter;
filter.pszName = L"Windows Executable";
filter.pszSpec = L"*.exe";
hr = pFileOpen->SetFileTypes(1, &filter);
break;
}
default:
{
break;
}
}
if (!SUCCEEDED(hr))
{
pFileOpen->Release();
CoUninitialize();
return false;
}
// Set the title
hr = pFileOpen->SetTitle(L"Please locate your Blender executable.");
if (!SUCCEEDED(hr))
{
pFileOpen->Release();
CoUninitialize();
return false;
}
// Show the Open dialog box.
hr = pFileOpen->Show(NULL);
if (!SUCCEEDED(hr))
{
pFileOpen->Release();
CoUninitialize();
return false;
}
// Get the file name from the open dialog box.
IShellItem *pItem;
hr = pFileOpen->GetResult(&pItem);
if (!SUCCEEDED(hr))
{
pItem->Release();
pFileOpen->Release();
CoUninitialize();
return false;
}
PWSTR pszFilePath;
hr = pItem->GetDisplayName(SIGDN_FILESYSPATH, &pszFilePath);
if (!SUCCEEDED(hr))
{
pItem->Release();
pFileOpen->Release();
CoUninitialize();
CoTaskMemFree(pszFilePath);
return false;
}
resultPath = pszFilePath;
CoTaskMemFree(pszFilePath);
pItem->Release();
pFileOpen->Release();
CoUninitialize();
return true;
}
示例8: FX_WINOLEAPI_
FX_WINOLEAPI_(void) FX_CoUninitialize(void)
{
CoUninitialize();
}
示例9: ContentPartnerThreadProc
DWORD WINAPI ContentPartnerThreadProc(LPVOID lpParameter)
{
CONTENT_PARTNER_THREAD_CONTEXT* pThreadCtx = NULL;
CComPtr<IWMPContentPartnerCallback> spCallback;
MSG msg = {0};
HRESULT hr = S_OK;
BOOL comInitialized = FALSE;
if(NULL == lpParameter)
{
hr = E_INVALIDARG;
goto cleanup;
}
pThreadCtx = static_cast<CONTENT_PARTNER_THREAD_CONTEXT*>(lpParameter);
if(NULL == pThreadCtx->pIStream)
{
hr = E_INVALIDARG;
goto cleanup;
}
hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
if(FAILED(hr))
{
ATLTRACE2("%x: ContentPartnerThreadProc(type %d): CoInitializeEx failed. %x\n", GetCurrentThreadId(), pThreadCtx->threadType, hr);
goto cleanup;
}
comInitialized = TRUE;
// Get a pointer to an IWMPContentPartnerCallback interface.
hr = CoGetInterfaceAndReleaseStream(
pThreadCtx->pIStream,
__uuidof(IWMPContentPartnerCallback),
reinterpret_cast<LPVOID*>(&spCallback) );
// The stream was released (even if CoGetInterfaceAndReleaseStream failed).
// Set the stream pointer to NULL.
pThreadCtx->pIStream = NULL;
if(FAILED(hr))
{
ATLTRACE2("%x: ContentPartnerThreadProc(type %d): Failed to get IWMPContentPartnerCallback interface. %x\n", GetCurrentThreadId(), pThreadCtx->threadType, hr);
goto cleanup;
}
if(NULL == spCallback)
{
hr = E_UNEXPECTED;
goto cleanup;
}
ATLTRACE2("%x: ContentPartnerThreadProc(type %d): Succeeded in getting IWMPContentPartnerCallback interface.\n", GetCurrentThreadId(), pThreadCtx->threadType);
// Make sure we have a message queue.
PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
// Tell the main thread that we are ready to receive messages.
SetEvent(pThreadCtx->hInitialized);
hr = ContentPartnerMessageLoop(pThreadCtx, spCallback);
cleanup:
if(NULL != pThreadCtx)
{
// Set this event here, just in case there was a "goto cleanup"
// before the event was set.
SetEvent(pThreadCtx->hInitialized);
// The thread that started this thread allocated a
// CONTENT_PARTNER_THREAD_CONTEXT structure.
// We must free that memory here.
if(NULL != pThreadCtx->pIStream)
{
// For some reason, CoGetInterfaceAndReleaseStream never got called.
// So release the stream here.
pThreadCtx->pIStream->Release();
pThreadCtx->pIStream = NULL;
}
ATLTRACE2("%x: ContentPartnerThreadProc(type %d): Returning %x\n", GetCurrentThreadId(), pThreadCtx->threadType, hr);
delete pThreadCtx;
pThreadCtx = NULL;
}
if(comInitialized)
{
CoUninitialize();
}
return hr;
}
示例10: main
void main()
{
// DirectShowのインスタンス宣言
IGraphBuilder *p_graph=NULL;
IMediaControl *p_control=NULL;
IMediaEvent *p_event=NULL;
HRESULT hr; // 処理結果
long event_code; // イベントコード
// COMライブラリの初期化
hr=CoInitialize(NULL);
// フィルタグラフのインスタンスを生成
hr=CoCreateInstance(
CLSID_FilterGraph, // フィルタグラフのクラスID
NULL, // 非アグリゲートオブジェクト
CLSCTX_INPROC_SERVER, // 呼び出し側と同じプロセスで実行
IID_IGraphBuilder, // グラフビルダでオブジェクト間通信する
(void **)&p_graph); // インスタンスを入れるポインタ
// フィルタグラフからIMediaControlを取得する
hr=p_graph->QueryInterface(
IID_IMediaControl, //IMediaControlのインターフェース指定
(void **)&p_control); //IMediaControlを入れるポインタ
// フィルタグラフからIMediaEventを取得する
hr=p_graph->QueryInterface(
IID_IMediaEvent, //IMediaEventのインターフェース指定
(void **)&p_event); //IMediaEventを入れるポインタ
// 再生するファイルを指定する
hr=p_graph->RenderFile(
L"C:\\workdir\\testh.mp3", // メディアファイル名
NULL); // 予約(NULL固定)
// ファイルのレンダリングに成功したらグラフを実行する
if(SUCCEEDED(hr))
{
// グラフを実行する
hr=p_control->Run();
if( hr == S_OK )
{
// グラフの実行に成功したら完了するまでイベントを待つ
p_event->WaitForCompletion(
INFINITE, // イベントタイマー(無期限)
&event_code); // イベント結果コード
}
}
// IMediaControlを開放する
p_control->Release();
// IMediaEventを開放する
p_event->Release();
// フィルタグラフを開放する
p_graph->Release();
// COMライブラリを開放する
CoUninitialize();
}
示例11: WinMain_
//.........這裏部分代碼省略.........
Sleep(3000);
Reboot_in_safemode_elevated();
return 0;
}
if (strncmp(&szCmdLine[i], winvncRebootForceHelper, strlen(winvncRebootForceHelper)) == 0)
{
Sleep(3000);
Reboot_with_force_reboot_elevated();
return 0;
}
if (strncmp(&szCmdLine[i], winvncSecurityEditorHelper, strlen(winvncSecurityEditorHelper)) == 0)
{
Sleep(3000);
winvncSecurityEditorHelper_as_admin();
return 0;
}
if (strncmp(&szCmdLine[i], winvncSecurityEditor, strlen(winvncSecurityEditor)) == 0)
{
typedef void (*vncEditSecurityFn) (HWND hwnd, HINSTANCE hInstance);
vncEditSecurityFn vncEditSecurity = 0;
char szCurrentDir[MAX_PATH];
if (GetModuleFileName(NULL, szCurrentDir, MAX_PATH)) {
char* p = strrchr(szCurrentDir, '\\');
*p = '\0';
strcat (szCurrentDir,"\\authSSP.dll");
}
HMODULE hModule = LoadLibrary(szCurrentDir);
if (hModule) {
vncEditSecurity = (vncEditSecurityFn) GetProcAddress(hModule, "vncEditSecurity");
HRESULT hr = CoInitialize(NULL);
vncEditSecurity(NULL, hAppInstance);
CoUninitialize();
FreeLibrary(hModule);
}
return 0;
}
if (strncmp(&szCmdLine[i], winvncSettings, strlen(winvncSettings)) == 0)
{
char mycommand[MAX_PATH];
i+=strlen(winvncSettings);
strcpy( mycommand, &(szCmdLine[i+1]));
Real_settings(mycommand);
return 0;
}
if (strncmp(&szCmdLine[i], winvncSoftwarecad, strlen(winvncSoftwarecad)) == 0)
{
Enable_softwareCAD();
return 0;
}
if (strncmp(&szCmdLine[i], winvncdelSoftwarecad, strlen(winvncdelSoftwarecad)) == 0)
{
delete_softwareCAD();
return 0;
}
if (strncmp(&szCmdLine[i], winvncRebootSafe, strlen(winvncRebootSafe)) == 0)
{
Reboot_in_safemode();
return 0;
}
示例12: watch_desktop_folders
static DWORD CALLBACK watch_desktop_folders( LPVOID param )
{
HWND hwnd = param;
HRESULT init = CoInitialize( NULL );
HANDLE dir0, dir1, events[2];
OVERLAPPED ovl0, ovl1;
char *buf0 = NULL, *buf1 = NULL;
DWORD count, size = 4096, error = ERROR_OUTOFMEMORY;
BOOL ret, redraw;
dir0 = CreateFileW( desktop_folder, FILE_LIST_DIRECTORY|SYNCHRONIZE, FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS|FILE_FLAG_OVERLAPPED, NULL );
if (dir0 == INVALID_HANDLE_VALUE) return GetLastError();
dir1 = CreateFileW( desktop_folder_public, FILE_LIST_DIRECTORY|SYNCHRONIZE, FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS|FILE_FLAG_OVERLAPPED, NULL );
if (dir1 == INVALID_HANDLE_VALUE)
{
CloseHandle( dir0 );
return GetLastError();
}
if (!(ovl0.hEvent = events[0] = CreateEventW( NULL, FALSE, FALSE, NULL ))) goto error;
if (!(ovl1.hEvent = events[1] = CreateEventW( NULL, FALSE, FALSE, NULL ))) goto error;
if (!(buf0 = HeapAlloc( GetProcessHeap(), 0, size ))) goto error;
if (!(buf1 = HeapAlloc( GetProcessHeap(), 0, size ))) goto error;
for (;;)
{
ret = ReadDirectoryChangesW( dir0, buf0, size, FALSE, FILE_NOTIFY_CHANGE_FILE_NAME, NULL, &ovl0, NULL );
if (!ret)
{
error = GetLastError();
goto error;
}
ret = ReadDirectoryChangesW( dir1, buf1, size, FALSE, FILE_NOTIFY_CHANGE_FILE_NAME, NULL, &ovl1, NULL );
if (!ret)
{
error = GetLastError();
goto error;
}
redraw = FALSE;
switch ((error = WaitForMultipleObjects( 2, events, FALSE, INFINITE )))
{
case WAIT_OBJECT_0:
if (!GetOverlappedResult( dir0, &ovl0, &count, FALSE ) || !count) break;
if (process_changes( desktop_folder, buf0 )) redraw = TRUE;
break;
case WAIT_OBJECT_0 + 1:
if (!GetOverlappedResult( dir1, &ovl1, &count, FALSE ) || !count) break;
if (process_changes( desktop_folder_public, buf1 )) redraw = TRUE;
break;
default:
goto error;
}
if (redraw) InvalidateRect( hwnd, NULL, TRUE );
}
error:
CloseHandle( dir0 );
CloseHandle( dir1 );
CloseHandle( events[0] );
CloseHandle( events[1] );
HeapFree( GetProcessHeap(), 0, buf0 );
HeapFree( GetProcessHeap(), 0, buf1 );
if (SUCCEEDED( init )) CoUninitialize();
return error;
}
示例13: LeaveMTA
static void LeaveMTA(void)
{
CoUninitialize();
}
示例14: CloseCamera
CCameraDS::~CCameraDS()
{
CloseCamera();
CoUninitialize();
}
示例15: InitSound
//=============================================================================
// 初期化
//=============================================================================
HRESULT InitSound(HWND hWnd)
{
HRESULT hr;
// COMライブラリの初期化
CoInitializeEx(NULL, COINIT_MULTITHREADED);
// XAudio2オブジェクトの作成
hr = XAudio2Create(&g_pXAudio2, 0);
if(FAILED(hr))
{
// COMライブラリの終了処理
CoUninitialize();
return E_FAIL;
}
// マスターボイスの生成
hr = g_pXAudio2->CreateMasteringVoice(&g_pMasteringVoice);
if(FAILED(hr))
{
if(g_pXAudio2)
{
// XAudio2オブジェクトの開放
g_pXAudio2->Release();
g_pXAudio2 = NULL;
}
// COMライブラリの終了処理
CoUninitialize();
return E_FAIL;
}
// サウンドデータの初期化
for(int nCntSound = 0; nCntSound < SOUND_LABEL_MAX; nCntSound++)
{
HANDLE hFile;
DWORD dwChunkSize = 0;
DWORD dwChunkPosition = 0;
DWORD dwFiletype;
WAVEFORMATEXTENSIBLE wfx;
XAUDIO2_BUFFER buffer;
// バッファのクリア
memset(&wfx, 0, sizeof(WAVEFORMATEXTENSIBLE));
memset(&buffer, 0, sizeof(XAUDIO2_BUFFER));
// サウンドデータファイルの生成
hFile = CreateFile(g_aParam[nCntSound].pFilename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
if(hFile == INVALID_HANDLE_VALUE)
{
return HRESULT_FROM_WIN32(GetLastError());
}
if(SetFilePointer(hFile, 0, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
{// ファイルポインタを先頭に移動
return HRESULT_FROM_WIN32(GetLastError());
}
// WAVEファイルのチェック
hr = CheckChunk(hFile, 'FFIR', &dwChunkSize, &dwChunkPosition);
if(FAILED(hr))
{
return S_FALSE;
}
hr = ReadChunkData(hFile, &dwFiletype, sizeof(DWORD), dwChunkPosition);
if(FAILED(hr))
{
return S_FALSE;
}
if(dwFiletype != 'EVAW')
{
return S_FALSE;
}
// フォーマットチェック
hr = CheckChunk(hFile, ' tmf', &dwChunkSize, &dwChunkPosition);
if(FAILED(hr))
{
return S_FALSE;
}
hr = ReadChunkData(hFile, &wfx, dwChunkSize, dwChunkPosition);
if(FAILED(hr))
{
return S_FALSE;
}
// オーディオデータ読み込み
hr = CheckChunk(hFile, 'atad', &g_aSizeAudio[nCntSound], &dwChunkPosition);
if(FAILED(hr))
{
return S_FALSE;
}
g_apDataAudio[nCntSound] = (BYTE*)malloc(g_aSizeAudio[nCntSound]);
hr = ReadChunkData(hFile, g_apDataAudio[nCntSound], g_aSizeAudio[nCntSound], dwChunkPosition);
if(FAILED(hr))
{
return S_FALSE;
//.........這裏部分代碼省略.........