// open handle to the camera device
hCamera = CreateFile(TEXT("CAM1:"), // "special" file name
GENERIC_READ|GENERIC_WRITE, // desired access
FILE_SHARE_READ|FILE_SHARE_WRITE, // sharing mode
NULL, // security attributes (=NULL)
OPEN_EXISTING, // creation disposition
FILE_FLAG_RANDOM_ACCESS, // flags and attributes
NULL); // template file (ignored)
if (hCamera == INVALID_HANDLE_VALUE)
{
return TPR_FAIL;
}
// open a pin for capture
hCapturePin = CreateFile(TEXT("PIN1:"), // "special" file name
GENERIC_READ|GENERIC_WRITE, // desired access
0, // sharing mode
NULL, // security attributes (=NULL)
OPEN_ALWAYS, // creation disposition
FILE_ATTRIBUTE_NORMAL, // flags and attributes
NULL); // template file (ignored)
if (INVALID_HANDLE_VALUE == hCapturePin)
{
return TPR_FAIL;
}
看这个函数
void CePimCommand(HWND hWnd, PIMTYPE ptData, UINT uDataCount, HANDLE *rghData, void *pReserved) {
if (uDataCount != 1)
return;
CEOID oid = *(CEOID *)rghData;
CEOID db_out = 0;
HANDLE hdb = CeOpenDatabase (&db_out, L"Contacts Database", 0, 0, NULL);
if (hdb == INVALID_HANDLE_VALUE)
return;
DWORD dwIndex = 0;
if (! CeSeekDatabase (hdb, CEDB_SEEK_CEOID, (DWORD)oid, &dwIndex))
return;
unsigned char *lpBuff = NULL;
DWORD cBuff = 0;
CEPROPID aPropID[PHONE_NUM] = {
PR_HOME_TELEPHONE_NUMBER_W,
PR_HOME2_TELEPHONE_NUMBER_W,
PR_BUSINESS_TELEPHONE_NUMBER_W,
PR_CALLBACK_TELEPHONE_NUMBER_W,
PR_CAR_TELEPHONE_NUMBER_W,
PR_MOBILE_TELEPHONE_NUMBER_W,
PR_RADIO_TELEPHONE_NUMBER_W,
PR_PRIMARY_TELEPHONE_NUMBER_W };
WORD dwPropIDs = PHONE_NUM;
[color=#FF0000]if (! CeReadRecordProps (hdb, CEDB_ALLOWREALLOC, &dwPropIDs, aPropID, &lpBuff, &cBuff))
return;[/color]
PhoneInfo numbers[PHONE_NUM];
memset (numbers, 0, sizeof(numbers));
CEPROPVAL *ppv = (CEPROPVAL *)lpBuff;
int iPhoneCnt = 0;
for (int i = 0 ; (i < dwPropIDs) && (iPhoneCnt < PHONE_NUM); ++i, ++ppv) {
if (ppv->wFlags & CEDB_PROPNOTFOUND)
continue;
switch (ppv->propid) {
case PR_HOME_TELEPHONE_NUMBER_W:
wcscpy (numbers[iPhoneCnt].szPhoneType, L"h");
break;
case PR_HOME2_TELEPHONE_NUMBER_W:
wcscpy (numbers[iPhoneCnt].szPhoneType, L"h2");
break;
case PR_BUSINESS_TELEPHONE_NUMBER_W:
wcscpy (numbers[iPhoneCnt].szPhoneType, L"w");
break;
case PR_CALLBACK_TELEPHONE_NUMBER_W:
wcscpy (numbers[iPhoneCnt].szPhoneType, L"c/back");
break;
case PR_CAR_TELEPHONE_NUMBER_W:
wcscpy (numbers[iPhoneCnt].szPhoneType, L"car");
break;
case PR_MOBILE_TELEPHONE_NUMBER_W:
wcscpy (numbers[iPhoneCnt].szPhoneType, L"m");
break;
case PR_RADIO_TELEPHONE_NUMBER_W:
wcscpy (numbers[iPhoneCnt].szPhoneType, L"radio");
break;
case PR_PRIMARY_TELEPHONE_NUMBER_W:
wcscpy (numbers[iPhoneCnt].szPhoneType, L"prim.");
break;
default:
continue;
}
if (wcslen (ppv->val.lpwstr) >= MAX_PHONE)
continue;
wcscpy (numbers[iPhoneCnt].szPhone, ppv->val.lpwstr);
++iPhoneCnt;
}
if (iPhoneCnt < PHONE_NUM) {
numbers[iPhoneCnt].szPhone[0] = '\0';
numbers[iPhoneCnt].szPhoneType[0] = '\0';
}
int ndx = DialogBoxParam (ghInst, MAKEINTRESOURCE (IDD_DIALOG1), NULL, WhichDlg, (LPARAM)numbers);
if ((ndx >= 0) && (ndx < iPhoneCnt)) {
PROCESS_INFORMATION pi;
STARTUPINFO si;
memset (&pi, 0, sizeof(pi));
memset (&si, 0, sizeof(si));
si.cb = sizeof(si);
DWORD bCP = CreateProcess (L"btdialer.exe", numbers[ndx].szPhone, NULL, NULL, FALSE, 0, NULL,
NULL, &si, &pi);
if (bCP) {
CloseHandle (pi.hThread);
CloseHandle (pi.hProcess);
}
}
return;
}
复制代码