-
周立功D12開發板中帶的WINDOWS XP驅動程序,在編譯后會出現USB設備不能正常工作. 以下是修改的代碼,修改后可以正常工作. 在d12.c和Ioctl.c中, 將+256去掉,這個會引去枚舉設備時,設備描述符的長度不對,修改后: siz = SIZEOF(USB_CONFIGURATION_DESCRIPTOR) 在d12.c中的D12_SelectInterface函數中, 設備查詢完接口后有一段代碼,也會引起驅動返回不對,需要屏蔽下面的代碼 // Retrieve the selected Configuration and Interface 修改上面兩處后,USB可以正常使用了.
標簽:
WINDOWS
D12
開發板
驅動程序
上傳時間:
2014-01-06
上傳用戶:it男一枚
-
//打開 USB 口讀寫, 由驅動程序的 Pipe 名確定
HANDLE hPipe = OpenMyDevPipe("MyPipe1") //驅動程序里面的 Pipe 名, 對應訪問某個端點的 I/O, 這里我亂寫的, 需要與驅動一致
if(hPipe != INVALID_HANDLE_VALUE) //打開 Pipe 成功
{
ReadFile(hPipe, Buffer, BufSize, &nBytesRead, NULL) //從 hPipe 里讀取數據到 Buffer 里
//WriteFile(hPipe, Buffer, BytesToWrite, &nBytesWritten, NULL) //把 Buffer 里面的 BytesToWrite 字節寫入 hPipe
CloseHandle(hPipe)
}
//使用 DeviceIoControl 訪問 USB 設備
HANDLE hDevice = OpenMyDevice()
if(hDevice != INVALID_HANDLE_VALUE) //打開設備成功
{
//這些 DeviceIoControl 功能都是由設備定義的, 具體看設備和驅動的資料
if(DeviceIoControl(hDevice, IOCTL_READ_xxxx, &IOBlock, SIZEOF(IOBLOCK), &c, 1, &nBytes, NULL))
{
//成功
}
CloseHandle(hDevice)
}
標簽:
Pipe
OpenMyDevPipe
MyPipe1
HANDLE
上傳時間:
2014-11-25
上傳用戶:stampede
-
學會對文件的記錄鎖定,及解鎖。#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main()
{
int fd
int i
struct {
char name[20]
uint ID
int age
} myrec
fd =open("name", O_RDWR|O_CREAT, 0755)
if (fd == -1) return -1
printf("Input your name:") scanf("%s", myrec.name)
printf("Inpute your ID :") scanf("%d", &myrec.ID)
printf("Input your age :") scanf("%d", &myrec.age)
lseek(fd, 0,SEEK_END)
lockf(fd, 1, 0)
write(fd, (void *)&myrec, SIZEOF(myrec))
lockf(fd, 0 ,0)
return 0
}
執行命令cc lock.c –o lock.out
Chmod +x lock.out
./lock.out
標簽:
記錄
上傳時間:
2016-01-04
上傳用戶:亞亞娟娟123
-
Programming interviews exposed
程序員面試寶典
本書取材于各大IT公司歷年面試真題(包括筆試題、口試題、電話面試、英語面試,以及邏輯測試和智商測試)。通過精確詳細的分類,把在應聘程序員(含網絡、測試等)過程中所遇見的常見考點分為21章。不僅對傳統的C系語言考點做了詳盡的解說,包括面向對象問題、SIZEOF問題、const問題、數據結構問題等。還根據外企出題最新特點,針對設計模式問題、C#問題、網絡問題、數據庫問題、NET問題等,做了深入的說明。
程序員面試寶典 英文版
Programming interviews exposed
標簽:
Programming
interviews
exposed
程序員面試
上傳時間:
2014-01-05
上傳用戶:gonuiln
-
主要源碼:
void CFDlg::OnChangeEdit1()
{
UpdateData()
m_strExt.MakeUpper()
m_list.ResetContent()
if(m_strExt.GetLength()==0) return
CStdioFile sf
if(sf.Open("FileExt.txt",Cfile::modeRead))
{
CString strTemp,strOut
while(sf.ReadString(strTemp))
{
if(strTemp.Left(m_strExt.GetLength()) ==m_strExt)
{
m_list.AddString(strTemp)
}
}
}
sf.Close()
m_list.SetCurSel(0)
this->OnSelchangeList2()
}
void CFDlg::OnSelchangeList2()
{
CString strTemp,strExt
m_list.GetText(m_list.GetCurSel(),strTemp)
strExt=strTemp.Left(strTemp.FindOneOf(" ")) //MessageBox(strExt)
CString strFileName ="eee."+strExt //MessageBox(strFileName)
SHFILEINFO shfi
memset(&shfi,0,SIZEOF(shfi)) //或者ZeroMemory(&shfi,SIZEOF(shfi))
::SHGetFileInfo(strFileName,
FILE_ATTRIBUTE_NORMAL,
&shfi,
SIZEOF(shfi),
SHGFI_ICON|SHGFI_USEFILEATTRIBUTES)
m_icon.SetIcon(shfi.hIcon)
}
標簽:
OnChangeEdit1
UpdateData
ResetConte
MakeUpper
上傳時間:
2013-12-20
上傳用戶:zl5712176
-
Wrox.Programming.Interviews.Exposed.2nd.Edition 這個是全英文的第二版,chm版本,
本書取材于各大IT公司歷年面試真題(包括筆試題、口試題、電話面試、英語面試,以及邏輯測試和智商測試)。通過精確詳細的分類,把在應聘程序員(含網絡、測試等)過程中所遇見的常見考點分為21章。不僅對傳統的C系語言考點做了詳盡的解說,包括面向對象問題、SIZEOF問題、const問題、數據結構問題等。還根據外企出題最新特點,針對設計模式問題、C#問題、網絡問題、數據庫問題、NET問題等,做了深入的說明。
標簽:
Programming
Interviews
Exposed
Edition
上傳時間:
2016-12-09
上傳用戶:13188549192
-
依次輸入單個字符到該數組中,直到輸入回車完成該字符數組的輸入。反向輸出該數組中的字符串內容。
// 輸入:This is Test! 輸出結果為:!tseT si sihT
// 并利用SIZEOF運算符,求出數組占用的內存字節數
標簽:
輸入
字符
數組
上傳時間:
2016-12-30
上傳用戶:lijianyu172
-
自然對界,Win32平臺下的微軟C編譯器(cl.exe for 80x86)在默認情況下采用如下的對齊規則:任何基本數據類型T的對齊模數就是T的大小,即SIZEOF(T)。比如對于double類型(8字節),
標簽:
上傳時間:
2013-12-14
上傳用戶:vodssv
-
client socket
include <sys/types.h>
include <sys/socket.h>
include <stdio.h>
include <netinet/in.h>
include <arpa/inet.h>
include <unistd.h>
int main()
{
int sockfd
int len
struct sockaddr_in address
int result
char ch = A
sockfd = socket(AF_INET, SOCK_STREAM, 0)
address.sin_family = AF_INET
address.sin_addr.s_addr = inet_addr("127.0.0.1")
address.sin_port = 9734
len = SIZEOF(address)
result = connect(sockfd, (struct sockaddr *)&address, len)
if(result == -1) {
perror("oops: client")
exit(1)
}
write(sockfd, &ch, 1)
read(sockfd, &ch, 1)
printf("char from server = c\n", ch)
close(sockfd)
exit(0)
}
標簽:
include
socket
sys
gt
上傳時間:
2017-07-29
上傳用戶:wab1981
-
兩個鏈表的交集
#include<stdio.h>
#include<stdlib.h>
typedef struct Node{
int data;
struct Node *next;
}Node;
void initpointer(struct Node *p){
p=NULL;
}
int printlist(struct Node* head){
int flag=1;
head=head->next;
/*
因為標記1的地方你用了頭結點,所以第一個數據域無效,應該從下一個頭元結點開始
*/
if(head==NULL)
printf("NULL\n");
else
{
while(head!=NULL)
{
if(flag==1)
{
printf("%d",head->data);
flag=0;
}
else
{
printf(" %d",head->data);
}
head=head->next;
}
printf("\n");
}
return 0;
}
struct Node *creatlist(struct Node *head)
{
int n;
struct Node *p1=(struct Node *)malloc(SIZEOF(struct Node));
p1->next=NULL;
while(scanf("%d",&n),n!=-1)
{
struct Node *pnode=(struct Node *)malloc(SIZEOF(struct Node));
pnode->next=NULL;
pnode->data=n;
if(head==NULL)
head=pnode;
p1->next=pnode;
p1=pnode;
}
return head;
}
struct Node *Intersect(struct Node *head1, struct Node *head2)
{
struct Node *p1=head1,*p2=head2;/*我這里沒有用頭指針和頭結點,這里是首元結點head1里面就是第一個數據,一定要理解什么事頭指針,
頭結點,和首元結點
具體你一定要看這個博客:http://blog.sina.com.cn/s/blog_71e7e6fb0101lipz.html*/
struct Node *head,*p,*q;
head = (struct Node *)malloc(SIZEOF(struct Node));
head->next = NULL;
p = head;
while( (p1!=NULL)&&(p2!=NULL) )
{
if (p1->data == p2->data)
{
q = (struct Node *)malloc(SIZEOF(struct Node));
q->data = p1->data;
q->next = NULL;
p->next = q;//我可以認為你這里用了頭結點,也就是說第一個數據域無效 **標記1**
p = q;
p1 = p1->next;
p2 = p2->next;
}
else if (p1->data < p2->data)
{
p1 = p1->next;
}
else
{
p2 = p2->next;
}
}
return head;
}
int main()
{
struct Node *head=NULL,*headt=NULL,*t;
//initpointer(head);//這里的函數相當于head=NULL;
// initpointer(headt);//上面已經寫了headt=NULL那么這里可以不用調用這個函數
head=creatlist(head);
headt=creatlist(headt);
t=Intersect(head,headt);
printlist(t);
}
標簽:
c語言編程
上傳時間:
2015-04-27
上傳用戶:coco2017co