|
USB is not like a serial port. You cannot just open it and send data on it. You will need to write a driver which is 'linked' to a specific hardware. When connected, the hardware will send its VID and PID (vendor ID and Product ID) and this will allow the operating system to load the specific driver. The link between the driver and the ID's is made through an inf file that contains the information.
Then, once your driver has been loaded, your application can then 'call' functions from the driver.
Hope this helps
|
|
|
|
|
Why doesn't this work?
I made a dialog based application in MFC. When the program is launched, I want it to be hidden. I'm using a global keyboard hook to respond to a key press and restore the window. This part works fine. It seems that i can hide the dialog by putting ShowWindow(SW_HIDE); in a button handler. So.. it works if i press a button on the dialog but not when the program starts.
This code from Microsoft MSDN does not do anything. But it should:
/* MyDialog.cpp */
#include "MyDialog.h"
BOOL CMyDialog::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_cMyEdit.SetWindowText("My Name"); // Initialize control values
m_cMyList.ShowWindow(SW_HIDE); // Show or hide a control, etc.
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
I've read in so many places that by putting ShowWindow(SW_HIDE); in the OnInitDialog(), it will hide the dialog when the program starts. It doesn't do anything for my program.
But ShowWindow(SW_MINIMIZE) works in that location for some reason!!!!!!!!
Even by setting the dialogs extended properties in the resource manager (unselecting the Visible checkbox), doesn't do anything.
If i put the ShowWindow(SW_HIDE); in the application's initialization (before the command to CMyDialog.DoModal()), I get an exception message "Debug Assertion Failure"!! Why?!!??!!?!?!??
|
|
|
|
|
|
hey
I want this function to return the location of the first letter of a substring in the searched string
int subsrc(char *target[BL], char *pattern[BL])
{<br />
if (strlen(pattern)>strlen(target))<br />
return NULL;<br />
int first_i;<br />
for (int i=0;i<strlen(target)-strlen(pattern);i++)<br />
{<br />
int j=0;<br />
if (target[i] == pattern[j])<br />
first_i = i;<br />
while (target[i] == pattern[j])
{<br />
i++;<br />
j++;<br />
if (pattern[j] == NULL)<br />
return first_i;<br />
}<br />
}<br />
return NULL;<br />
}
thanks dudes
|
|
|
|
|
xlntbno17 wrote:
I want this function to return the location of the first letter of a substring in the searched string
What about strstr function!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Each of these functions returns a pointer to the first occurrence of strCharSet in string, or NULL if strCharSet does not appear in string. If strCharSet points to a string of zero length, the function returns string.
i SUCK with pointers so help me out here
how would I know what number of the array it would be?
thanks
|
|
|
|
|
xlntbno17 wrote:
Each of these functions returns a pointer to the first occurrence of strCharSet in string, or NULL if strCharSet does not appear in string. If strCharSet points to a string of zero length, the function returns string.
Thats What strstr function defined in string.h do.
Is you have to code your own function for that?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
What would be the best way to extract something between two substrings?
Like if I'm looking through HTML code and i want whats between <tag> and </tag>
from:
"<tag>$20.00</tag>"
i would want to extract "$20.00"
but it could be anything
|
|
|
|
|
xlntbno17 wrote:
Like if I'm looking through HTML code and i want whats between and
Hope this code work well for you!
BOOL CViewSource::Return_Element_Value(const char *lpszOriginalString, const char *lpszElementVar, char *lpszReturnValue)
{
char csOpenTag[20],csCloseTag[20];
int start_pos, ending_pos, closing_br;
int i,j;
char *pdest;
sprintf(csOpenTag,"<%s>",lpszElementVar);
pdest = ::strstr(lpszOriginalString,csOpenTag);
start_pos = pdest - lpszOriginalString + 1;
if(pdest==NULL)
return FALSE;
pdest=NULL;
sprintf(csCloseTag,"</%s>",lpszElementVar);
pdest = ::strstr(lpszOriginalString,csCloseTag);
ending_pos = pdest - lpszOriginalString + 1;
if(pdest==NULL)
return FALSE;
closing_br=start_pos+strlen(csOpenTag);
char *temp=new char[(ending_pos-start_pos)+10];
for(i=closing_br-1,j=0;i<ending_pos-1;i++,j++)
temp[j]=lpszOriginalString[i];
temp[j]='\0';
strcpy(lpszReturnValue,temp);
return TRUE;
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Hello,
xlntbno17 wrote:
how would I know what number of the array it would be?
Some simple pointer arithmic will do your magic:
char* pszYourString = "This is some string";
char* pszPattern = "some";
char* pszDest = strstr( pszYourString, pszPattern );
int nPos = pszDest - pszYourString + 1;
Look in MSDN[^] for more information on strstr
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Bob Stanneveld wrote:
int nPos = pszDest - pszYourString + 1;
There's no need to add one to the result. Doing so creates an off-by-one error.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Well, the + 1 is there in MSDN.. This position in this case, is not the zero based index to an array, but the position starting at 1.
Do VB or Pascal have zero based indices?
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Bob Stanneveld wrote:
Do VB or Pascal have zero based indices?
For VB, it depends on Option Base. Yes for Pascal.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
DavidCrow wrote:
Pascal have zero based indices?
For VB, it depends on Option Base. Yes for Pascal.
Nope, Pascal don't have ZERO based Index, Index of array in pacal start with 1!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
ThatsAlok wrote:
Nope, Pascal don't have ZERO based Index,
Actually it does:
program abc;
var
numbers:array[0..9] of integer;
x:integer;
begin
for x:=0 to 9 do
numbers[x]:=x;
end.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
DavidCrow wrote:
program abc;var numbers:array[0..9] of integer; x:integer;begin for x:=0 to 9 do numbers[x]:=x; end.
I have done pascal in First Year of my Engg Graduation. When I convert from pascal to C++ , i always face problem due to array INDEX as Pascal Index start from 1 and in C++ index start from 0. May be you are right, I havn't learn PASCAL much
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
I am bit concerned over the issue of fragmentation problem due to dynamic memory allocation in real time applications that have to run for long say 1 year. How to avoid it? What if in some scenario you must dynamically allocate the memory occasionaly of different block size?
Any one here, who has developed some performance critical application which runs for long and have addressed these issues?
Thanks
Muhammad Shoaib Khan
http://geocities.com/lansolution
|
|
|
|
|
If memory is continually allocated but never freed, the program, and probably most everythying else, will come to a halt.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
hey guys...an english guy's life between u hands..so plz help me in this..i want to make apassword for my program(in visual c++) that will be invisible for the user (like that in da mail)i mean it appears as STARS shape..i want to make this by using (STRING)if that possible ..or just any simple code..iam stuck hear guys so plz replay me as fast as u can...
|
|
|
|
|
Is it a Windows application ? If so, the text box has a password property. Set it to true, and when you type in it, it will only show ******.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thank u Mr christian for u help ..i realy apreciate u time and u opinion..i have used so simple code that make user insert username && password but my prob is i cant make password invisible for the user ( appears as stars shape)
#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
void main()
{
string str1,str2;
string username ("ourteam");
string password ("cool");
cout<<"plz enter username"<<endl;
cin="">>str1;
cout<<"plz enter password"<<endl;
cin="">>str2;
if(str1==username && str2==password)
{
cout<<"hello guys"<
|
|
|
|
|
#include <conio.h>
string s;
char c;
while ((c = getch()) != 13)
{
s += c;
cprintf("*");
}
Now "s" contains the string user entered.
Do this for both username and password.
this is this.
|
|
|
|
|
Hi,
I need an efficient/simple password encryption/decryption algorithm/code so that I can use in my VC++ application.
I actually looked in the net a found various utilities but not been able to decide which one to go for?
Thanks,
|
|
|
|
|
|
I tried both the links but most of the algorithms which use XOR do not work for passwords like abcd1, abcde1, abcdef12, abcdef12ghijklmnop etc.
Do you have any other algorithms which will work for all the characters? Imean encrypt/decrypt any given data?
|
|
|
|