|
Sounds strange that you are able to open a resource that is not connected to the system...
What "filename" are you providing as argument in the call to ::CreateFile() ?
Is ::CreateFile() actually returning a valid handle, i.e. it doesn't return INVALID_HANDLE_VALUE which is defined as -1?
Is ::ReadFile() really returning TRUE ?
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Suppose i just connect a Serial port cable to computers Serial port, and at the other end a reader is not connected, now a handle is successfully created.
now if i use ReadFile() it waits infinitely to receive a response !
on the other hand if i set some Time outs using SetCommTimeouts ()
the Readfile () successfully executes as it times out, i.e it doesnot receive response within stipulated time period, but it doesnot give error if the reader is not connected, it reads Zero bytes
|
|
|
|
|
kapardhi wrote: Serial port cable to computers Serial port
Ahh, that explains it.
I assumed it was a USB device, sorry about that.
kapardhi wrote: now if i use ReadFile() it waits infinitely to receive a response !
Don't know if you by this mean that the call blocks, but if that's a problem you can use overlapped mode instead. I would recommend overlapped mode whether this is a problem or not. However, the read request to the driver will not be completed until the timeout set by ::SetCommTimeouts() expires.
If the card reader would set one of the signals, e.g. DSR or CTS, to an active state it would be possible to use ::GetCommModemStatus() to check if the device is present. Have you investigated this possibility?
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Sorry !!
Not yet satisfied!
Presently i send commands and wait for response , but i need some better approach !
|
|
|
|
|
How about answering my question about hardware signals from the card reader?
If you cannot use the hardware to detect whether the device is present, you have to start communicating with the device.
Even if this is the unfortunate case, the device should respond fairly rapidly without worrying about degrading performance from a user perspective.
Perhaps this article[^] can give you some ideas.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
As you know, PE files are diveded into parts, each for a certain perpose (e.g. Code, Uninitialaized Data, Initialized Data, ...).
But I want the compiler not to do so! I'd like to put the entire program into a single section.
Thnx in advance . . .
|
|
|
|
|
Hi All,
Now i am trying to plot a graph using MSChart in MFC.i want to plot a Graph whose X-axis is Number of samples(range is 1,2,3,4,5 like that), Y-axis is Time(range is 0.5,1,1.5,2,2.5).While i am trying to change X& Y axis range using the MSChart Properties, The image of the Chart in the Dialog becomes smaller...
I need to adjust the X and Y -axis Range in the Graph?
How can i do this?
|
|
|
|
|
The following code is not compiling in .Net 1.1
[code]
This is the main project file for VC++ application project
// generated using an Application Wizard.
#include "stdafx.h"
#include <stdafx.h>
#include <ocilib.h>
using namespace System;
int _tmain(int argc, char *argv[])
{
OCI_Connection* cn;
OCI_Statement* st;
OCI_Resultset* rs;
int Counter = 0;
int ret;
FILE *TablesFile;
char *Database, *UserName, *UserPassword, *StartDate, *EndDate;
char Message[256] = "";
/* for (i=0; i<argc;> * {
* printf("%d %s\n", i, argv[i]);
* }
*/
Database = argv[1];
UserName = argv[2];
UserPassword = argv[3];
StartDate = argv[4];
EndDate = argv[5];
OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT);
cn = OCI_ConnectionCreate(Database, UserName, UserPassword, OCI_SESSION_DEFAULT);
st = OCI_StatementCreate(cn);
sprintf(Message, "select MemNumber,Turnover from (select mem_number MemNumber,sum(trans_turnover) Turnover from members join transact on mem_number = trans_code where Trans_date between '%s' and '%s' and mem_barred = 0 group by mem_number order by turnover desc ) where rownum <=200", StartDate, EndDate);
// printf("%s\n",Message);
OCI_ExecuteStmt(st, Message);
// OCI_ExecuteStmt(st,"select MemNumber,Turnover from (select mem_number MemNumber,sum(trans_turnover) Turnover from members join transact on mem_number = trans_code where Trans_date between '01-Jan-2004' and '14-Oct-2008' and mem_barred = 0 group by mem_number order by turnover desc ) where rownum < 201");
rs = OCI_GetResultset(st);
// printf("OCI_GetResultset() returns rs = %x\n", rs);
TablesFile = fopen("Tables.html", "wt");
while (OCI_FetchNext(rs))
{
fprintf(TablesFile, "% 4d - %u\n", ++Counter, OCI_GetDouble(rs, 1));
}
ret = fclose(TablesFile);
OCI_Cleanup();
return EXIT_SUCCESS;
}
[/code]
.Net returns C1004: unexpected end of file found
and as hard as I look I cannot see a missing or additional brace.
|
|
|
|
|
Member 5605240 wrote: using namespace System;
shouldn't this be using namespace std;
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Just go to the end of the file and press ENTER and save it again. Please inform us if it worked or not.
Thank you masters!
|
|
|
|
|
|
Why can't you do that at design time? Or is this range on the second dialog going to be dynamic?
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
|
MsmVc wrote: Becouse my Edit Box control on dailog B
So what?! Can you not just edit the dialog B at design time? Are you creating it dynamically?
Do I have to get bits and pieces by asking a thousand questions? Why can't you just give all the relevant information in your first post?
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Deleting your post is RUDE. That makes you look more unprofessional.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Hi all,
i have this string "random@mail.com", it can also be "email@yahoo.com", basically the string is an email address now how would i eliminate the characters just to get the domain name "mail.com" or "yahoo.com".
Thanks,
Jayjay
|
|
|
|
|
find the @ character position , copy the string from that position to end of the actual string
|
|
|
|
|
Simple function:
int GetDomain (const char *email, char *domain)
{
if (!email || !domain) return -1;
char *c= strchr ((char*)email, '@');
if (!c) return -2;
strcpy (domain, c+1);
return 0;
}
...
char a[100]="";
int e= GetDomain ("sample@domain.es", a);
|
|
|
|
|
const char * getDomain(const char szMail)
{
const char * szDomain;
if (! szMail ) return NULL;
szDomain = szMail +strlen(szMail);
while (szDomain-- != szMail )
{
if (*szDomain == '@') break;
}
if (szDomain==szMail) return NULL;
return ++szDomain;
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I'm leaving error checking and other dodgy stuff to you as an exercise.
const char *szEmail= "myname@mydomain.com";
std::cout<< strstr(szEmail, "@")+1 <<std::endl; Output: mydomain.com
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Rajesh R Subramanian wrote: I'm leaving error checking and other dodgy stuff to you as an exercise.
That's unfair to other competitors
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: That's unfair to other competitors
[Chris Tucker voice] I tell ya what: I am an unfair man. [/Chris Tucker voice]
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Rajesh R Subramanian wrote: [Chris Tucker voice] I tell ya what: I am an unfair man. [/Chris Tucker voice]
[Anton Chigurh voice]: You stand to win everything. Call it [/Anton Chigurh voice]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Good try, i've got another one:
char *email="myemail@mail.com";
char *domain= strchr(email,'@')?strchr(email,'@')+1: 0;

|
|
|
|
|
Welcome to the code obfuscation club. Nah, just kidding.
Nice attempt, BTW.
[add] You know the master of obfuscations[^], right? [/add] Jus' kiddin' Carlo.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|