//int WinMain(HINSTANCE hInstance,HINSTANCE hPreInstance,LPSTR lpCmdLine,int nCmdShow) int main(void) { CHAR szLogicDriveStrings[BUFSIZE]; PCHAR szDrive; ZeroMemory(szLogicDriveStrings, BUFSIZE); GetLogicalDriveStrings(BUFSIZE - 1, szLogicDriveStrings); szDrive = (PCHAR)szLogicDriveStrings; //puts(szDrive) do { puts(szDrive); if (!GetDriverInfo(szDrive)) { printf("\nGet Volume Information Error:%d", GetLastError()); } szDrive += (lstrlen(szDrive) + 1); } while (*szDrive != '\x00'); //system("PAUSE"); return 0; }
//================================================================================================== int main(int argc, char **argv) { struct sigaction sigact; int chose, res; int closeFlag = 0; struct timeval; Byte handleNum; options_t options; get_options(argc, argv, &options); print_options(&options); if (DTV_Initialize(options.dev_handle) == ERR_INVALID_DEV_TYPE) { return 0; } sigact.sa_handler = sighandler; sigemptyset(&sigact.sa_mask); sigact.sa_flags = 0; sigaction(SIGINT, &sigact, NULL); sigaction(SIGTERM, &sigact, NULL); sigaction(SIGQUIT, &sigact, NULL); sigaction(SIGPIPE, &sigact, NULL); fprintf(stderr, "\n========== ITEtech Linux DTV receiver control program ==========\n"); GetDriverInfo(); fprintf(stderr, "================================================================\n"); if (ChannelLock(&options) < 0) { fprintf(stderr, "Lock channel fail!\n"); } else { if (options.stat_count >= 0) { ChannelStatisticTest(&options); } else { if (options.ts_filename) { dvbout(&options); } else { dvbtraffic(&options); } } } DTV_Finalize(); return 0; }
int main() { CHAR szLogicalDriveStrings( BUFSIZE ); PCHAR szDrive; ZeroMemory( szLogicalDriveStrings, BUFSIZE ); // 获取逻辑驱动器卷标名 GetLogicalDriveStrings( BUFSIZE-1, szLogicalDriveStrings ); szDrive = (PCHAR)szLogicalDriveStrings; // 循环处理每个卷 do { if ( !GetDriverInfo(szDrive) ) printf( "\nGet Volume Information Error: %d", GetLastError() ); szDrive += (lstrlen(szDrive)+1); }while( *szDrive != '\x00' ); }
void CPrinterInfo::GetNames(HGLOBAL hDevNames, BOOL fUseWinIni /*=TRUE*/) { /* // In case we fail. */ m_csDriverName.Empty(); m_csDeviceName.Empty(); m_csOutputName.Empty(); m_csPrinterName.Empty(); /* // Now try and get the printer info. */ LPDEVNAMES pDevNames = NULL; if (hDevNames != NULL) { pDevNames = (LPDEVNAMES)::GlobalLock(hDevNames); } CString csWinDevice; CString csWinDriver; CString csWinOutput; if (fUseWinIni) { char szBuffer[256]; ::GetProfileString("windows", "device", "?", szBuffer, sizeof(szBuffer)); if (strcmp(szBuffer, "?") != 0) { csWinDevice = strtok(szBuffer, ","); csWinDriver = strtok(NULL, ","); csWinOutput = strtok(NULL, ","); } } if (pDevNames == NULL) { /* // We don't have a printer name. Use defaults. */ TRACE0("*** Using WIN.INI ***\n"); m_csDeviceName = csWinDevice; m_csDriverName = csWinDriver; m_csOutputName = csWinOutput; } else { /* Extract the driver name. */ m_csDeviceName = (LPCSTR)pDevNames + pDevNames->wDeviceOffset; m_csDriverName = (LPCSTR)pDevNames + pDevNames->wDriverOffset; m_csOutputName = (LPCSTR)pDevNames + pDevNames->wOutputOffset; ::GlobalUnlock(hDevNames); } #ifdef WIN32 /* // We don't want this transient WINSPOOL name. // If it shows up, go back to the WIN.INI device= name if we have one. */ if (m_csDriverName.CompareNoCase("WINSPOOL") == 0) { if (!csWinDriver.IsEmpty()) { m_csDriverName = csWinDriver; } } m_csPrinterName = m_csDeviceName; /* // Get the actual driver name (not the name the user gave it). */ HANDLE hPrinter; if (OpenPrinter((LPSTR)(LPCSTR)m_csDeviceName, &hPrinter, NULL)) { PRINTER_INFO_2* pInfo2; if ((pInfo2 = (PRINTER_INFO_2*)GetPrinterInfo(hPrinter, 2)) != NULL) { if (pInfo2->pDriverName != NULL) { m_csDeviceName = pInfo2->pDriverName; } delete [] pInfo2; } DRIVER_INFO_2* pDrvInfo2; if ((pDrvInfo2 = (DRIVER_INFO_2*)GetDriverInfo(hPrinter, 2)) != NULL) { if (pDrvInfo2->pDriverPath != NULL) { m_csDriverName = pDrvInfo2->pDriverPath; } delete [] pDrvInfo2; } ClosePrinter(hPrinter); } #else m_csPrinterName = m_csDeviceName; #endif CString csOutput; csOutput.Format("Drv: '%s'; Dev: '%s'; Out: '%s'\n(Name: '%s')", (LPCSTR)m_csDriverName, (LPCSTR)m_csDeviceName, (LPCSTR)m_csOutputName, (LPCSTR)m_csPrinterName); // AfxMessageBox(csOutput); TRACE("%s\n", csOutput); }
DWORD CUsbIo::OpenPath( const TCHAR* Name, bool CheckApiVersion /*= true*/ ) { DWORD Status; HANDLE h; if ( FileHandle != NULL ) { // already open return USBIO_ERR_DEVICE_ALREADY_OPENED; } // try to open the device driver h = ::CreateFile( Name, // LPCTSTR lpFileName, GENERIC_READ | GENERIC_WRITE, // access mode FILE_SHARE_WRITE | FILE_SHARE_READ, // share mode NULL, // security desc. OPEN_EXISTING, // how to create FILE_FLAG_OVERLAPPED, // file attributes NULL // template file ); if ( h == INVALID_HANDLE_VALUE ) { Status = GetLastError(); // map ERROR_FILE_NOT_FOUND to a specific USBIO error code if (Status == ERROR_FILE_NOT_FOUND) { Status = USBIO_ERR_DEVICE_NOT_FOUND; } } else { // save handle FileHandle = h; // init the event with auto reset, not signaled Overlapped.hEvent = CreateEvent(NULL ,FALSE ,FALSE ,NULL); if ( Overlapped.hEvent == NULL ) { Status = USBIO_ERR_NO_MEMORY; Close(); } else { // now get version info USBIO_DRIVER_INFO info; Status = GetDriverInfo(&info); if ( Status != USBIO_ERR_SUCCESS ) { // failed Close(); } else { CheckedBuildDetected = (info.Flags&USBIO_INFOFLAG_CHECKED_BUILD) ? TRUE : FALSE; DemoVersionDetected = (info.Flags&USBIO_INFOFLAG_DEMO_VERSION) ? TRUE : FALSE; LightVersionDetected = (info.Flags&USBIO_INFOFLAG_LIGHT_VERSION) ? TRUE : FALSE; // success Status = USBIO_ERR_SUCCESS; // now check the API version if (CheckApiVersion) { // major version must match the driver version. if ( (info.APIVersion & 0xff00) != (USBIO_API_VERSION & 0xff00) || (info.APIVersion & 0xff) < (USBIO_API_VERSION & 0xff)) { // wrong version Status = USBIO_ERR_VERSION_MISMATCH; Close(); } } } } } return Status; }
//int main(int argc, char **argv) int rx(Byte handleNum) { int chose, res; int closeFlag = 0; struct timeval; //Byte handleNum; if(DTV_Initialize(handleNum) == ERR_INVALID_DEV_TYPE) return 0; printf("\n========== ITEtech Linux DTV Testkit ==========\n"); GetDriverInfo(); printf("\n===============================================\n"); while (!closeFlag) { printf("\n======= ITEtech Linux DTV Testkit =======\n"); printf("\n1. Lock Channel "); printf("\n2. Singal Quality Statistics "); printf("\n3. Record & Analyze Packets "); printf("\n4. Mutil-Channel Lock Test "); printf("\n5. Read/Write Register "); printf("\n6. echo "); printf("\n7. ULE rx "); printf("\n0. Quit "); printf("\n=> Please Input Your Choice: "); res = scanf("%d", &chose); switch (chose) { case 1: if (ChannelLock() < 0) { printf("Lock channel fail!\n"); } break; case 2: ChannelStatisticTest(); break; case 3: PacketTest(); break; case 4: MultiChannelTest(); break; case 5: RWRegister(); break; case 6: echoRX(); break; case 7: ule_rx(); break; case 0: closeFlag = 1; break; } } DTV_Finalize(); return 0; }