|
Hi,
Thanks for ur reply.
So is it enough to include windef.h in my C++ program and write my own header file.
so with typdef can i convert all windows data and use them in my C++ file.
nev
|
|
|
|
|
nev, i don't want to insult you but this is all beginner C++ issues. You should probably take the time to study these basic language concepts so that you understand them before you attempt to implement your project.
But, that's just my opinion... I could be wrong.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
|
hi mike,
I have a USB chip.They have given me the device driver and thier function looks like this.
http://www.ftdichip.com/knowledgebase/d2xx/manual/userguide.htm
write function is:
FT_STATUS FT_Write ( FT_HANDLE ftHandle, LPVOID lpBuffer, DWORD dwBytesToWrite, LPDWORD lpdwBytesWritten ) .They actually imported functions from win32 api(kernell32.dll).
where FT_status is ULONG data type.
http://www.ftdichip.com/knowledgebase/d2xx/manual/userguide.htm
If i just want to write a C++ program to write my data into LPVOID lpbuffer.How do i di it.I want my function to look like
write(int addr,unsigned char data);
nev
|
|
|
|
|
Helloo sir,with all due respect,
could you give me useful pointer over smartcard api's
thanks
-----------------------------
"I Think It will Work"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Alok the programmer wrote:
could you give me useful pointer over smartcard api's
What kind of API. Are you talking about a smart card reader or the API of the card itself. The API's usually depend on the hardware being used to read the cards. Google is your best friend in these matters unless you know the manufacturer of your hardware/card.
Michael
CP Blog [^]
|
|
|
|
|
naveen_vi wrote:
Since c++ doesnt recognise data types like DWORD,BUFFER etc..I am struck.
DWORD, BUFFER etc are all Windows types. If you are writing a Windows application then these will be available in any C++ compiler. Most of these are defined in WINDEFS.H and map to standard C++ types.
Your question is a little vague. More information would allow us to help you better.
Michael
CP Blog [^]
|
|
|
|
|
Hi Everybody,
I would like to know how to find a substring in a string. finding should be done without case sensitive.
for example consider a string HomeWork.
I want to search wheather worK is there in the above string.
Let me know any function that perform this type of searching.
I tried strstr(), but it did not work because it is case sensitive.
Thanks in Advance.
|
|
|
|
|
|
DELIVER THE PROMISE wrote:
I tried strstr(), but it did not work because it is case sensitive.
So convert both to the same case and go from there.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
As DavidCrow said - probably the easiest way would be to make all strings the same case, and then compare. E.g., use strupr on the string and the substring, then do an strstr.
The other option is to write the search yourself. That actually would not be that hard to do, and perhaps that is the purpose of your homework anyway.
"Fish and guests stink in three days." - Benjamin Franlkin
|
|
|
|
|
Thanks for helping me out. I have converted both strings into lower and searched.
Thanks a lot
;););););););););)
|
|
|
|
|
I am writting to the Serial Port using m_port.Write(sBuf, 7); .
This writes 7 bytes stored in the array sBuf, which is an array of chars.
However, it only works for numbers upto 0x7f (127), anything more than that loses the upper bit. Any ideas for a fix?
Ali
|
|
|
|
|
What is the type of m_port?
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Sorry, I realised as soon as I submitted it that I hadn't put enough info, but couldn't find 'Edit'.
'm_port' is a class which handles the serial comms.
This is the code for the function 'Write'
DWORD CSerialPort::Write(const void* lpBuf, DWORD dwCount)<br />
{<br />
ASSERT(IsOpen());<br />
ASSERT(!m_bOverlapped);<br />
<br />
DWORD dwBytesWritten = 0;<br />
int nResult = WriteFile(m_hComm, lpBuf, dwCount, &dwBytesWritten, NULL);<br />
if (!nResult)<br />
{<br />
TRACE(_T("Failed in call to WriteFile\n"));<br />
AfxThrowSerialException();<br />
}<br />
<br />
return dwBytesWritten;<br />
}
So it actually uses 'WriteFile' to write the data to the serial port.
Ali
|
|
|
|
|
Alison Pentland wrote:
anything more than that loses the upper bit
This may be a stupid question but… how do you know that? If you mean the application reading the data is missing the upper bit how do you know it is not the reading that is the problem?
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
It is not a stupid question, here is the answer.......
I have an analyser attached to the the serial port, it displays all the data from the Rx & Tx lines on the RS232 port. My code 'talks' to an instrument that we design and I write the firmware for.
The problem is that when I write 0x96 to the port I get 0x16 out. I have traced through the code and I can see the data in the array is correct when I pass it to the 'WriteFile' function.
I can't understand it as it is the same code I have been using for months! Any ideas gratefully received.
Thanks,
Ali
|
|
|
|
|
Big Big Smile!
Thank you, your question has prompted me to find my problem. I realised that the only reason I believed that I had a problem was the display on the 'Serial Analyser'. I was on holiday last week and it had a firmware upgrade while I was away. So I checked through the settings and found that the number of data bits was set to 7! (when it should have been & was previously 8)
I use the Analyser almost every day and I never change the settings, so it just didn't occur to me that it might be wrong ..... until you asked me how I knew it was writing the data that was the problem. You can probably tell I am very happy to have resolved it!
Thank you, thank you, thank you
Ali
|
|
|
|
|
Hi. I recently wrote a small MFC app that saves files in my own format .cmp
I also managed to associate this file extension with windows so my files have their own cutom icon rather than the default windows one. I learned how to do it from here (cool stuff): http://www.codeproject.com/w2k/extendingshell.asp
Now I am facing one problem. When I double-click on any saved file say stored on my desktop then my application opens as it should but it doesnt open my file.
Obviously its because when my application initializes it should know the name of the file that I selected to open but I am not sure how to retieve this info. I guess when I right-click on the saved file and select from a context menu "Open this (.cmp) in my app" the shell Command will call my app and somehow pass the name of the file.
So basically I am not sure how to read this command line arguments in my MFC app so I could get the name of the file and open it immediately after my app initialization. Actually would it be a command line or some other way of doing it? how do I tell my app what file I am opening.?
Please let me know if its very easy solution for it.
In that tutorial the author calls:
C:\Windows\Notepad.exe %1
but I guess "%1" means nothing to my app as my app would not recognise what that is. I think I should replace %1 with my own command like "open" or "print" to distinguish the action my app should perform. Am I right? Please let me know if you could. Thank you..
|
|
|
|
|
Did you use AppWizard to create your application? If so, a .reg file would have been created in the project. Has RegisterShellFileTypes() been called from the application object? This is what registers the document types with the shell (e.g., Windows Explorer). After that, you should see a .cmp key under the HKEY_CLASSES_ROOT hive. Note the value of the (Default) value. That should also exist under the HKEY_CLASSES_ROOT hive. For example, if the extension were .txt instead, you'd see a .txt key under the HKEY_CLASSES_ROOT hive. The (Default) value is txtfile, so you'd also see a txtfile key under the HKEY_CLASSES_ROOT hive. The HKEY_CLASSES_ROOT\txtfile\shell key will have keys named open, print, and printto. Note the difference (the /p command-line parameter) between the command that opens versus the command that prints.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
No. I did update registry myself. all keys are added and working well! its just when you right-click on the filename.cmp it opens teh program which is correct but the programas isnt able to know what file was selected.
|
|
|
|
|
robert_s wrote:
...but the programas isnt able to know what file was selected.
Did you add the %1 parameter to the registry entry? That is what gets replaced with the selected file? In your application, you can get access to the command-line parameters via the m_lpCmdLine member.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Yes I added %1 in registry
c:\Documents and Settings\user\My Documents\Prog\Prog.exe %1
Is it correct?
but I am not sure whether it should be separated by space or a comma ','
when I add the following code to:
BOOL CProgView::PreCreateWindow(CREATESTRUCT& cs)
{.....
LPTSTR str = ::GetCommandLine();
AfxMessageBox(str);
..}
The str contains one long string
"c:\Documents and Settings\user\My Documents\Prog\Prog.exe c:\Docum~1\use~\Desktop\test~1.cmp"
I guess its what I should get but its a bit silly to have one long string as it will be a hassel to separate one argument from the other as the are blank spaces all over the place so it will be hard to determine where to split it.
|
|
|
|
|
robert_s wrote:
c:\Documents and Settings\user\My Documents\Prog\Prog.exe %1
Is it correct?
Be sure and put double-quotes around the %1.
robert_s wrote:
its a bit silly to have one long string as it will be a hassel to separate one argument from the other as the are blank spaces all over the place so it will be hard to determine where to split it.
Can you use the CCommandLineInfo class? If not, __argv[1] is always available.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi,
Is it possible to have a multidimensional CArray (how do you declare it?) or do you have to write one yourself?
tnx for your help.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|