|
-->here my latest code but still has a lot of error
// P310C Encoder
#include "cst25110.h"
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
SCR_SCR_PARAMS myParams; // each instance represents one encoder
void main(void)
{
.
.
myParams.scrAttr.Port = 1; // e.g., target encoder attached to com 1
ctOpen(&myParams.scrAttr);
.
subfunction();
.
.
ctClose(&myParams.scrAttr);
}
void subfunction()
{
.
iccApduExchange(&myParams); // note we did not declare in this function
}
// P310C Smart Card Encoder
ctOpen();
ctEngageCard(); // engage contact station
ctColdReset(); // for SLE 4428 cards.
int main () {
char buffer[256];
ifstream examplefile ("CADID_listing.txt"); // The CAD_PIN, CARD_TYPE, CAD_ID will not be encoded to the card
if (! examplefile.is_open()) // For example each card will be encoded by 55555 00000001 0410000001 ( CAD_PIN, CARD TYPE and CAD_ID )
{ cout << "Error opening file"; exit (1); }
while (! examplefile.eof() )
{
examplefile.getline (buffer,100);
cout << buffer << endl;
}
return 0;
}
ctDeactivate(); // power down smartcard
ctDisengageCard(); // disengage contact station
ctClose();
-> And this is cst25110.h
/*
CST25110.h - Header file for CST25110.DLL API Development
Copyright 2003 Innolab Pte Ltd
*/
// 1. TYPE DEFINITIONS
typedef struct
{
HANDLE hComm; // Transparent handle, leave it alone!
DWORD Port; // Serial Target
DWORD Target; // indicate slot when necessary esp. APDU exchange
} SCR_SCR_ATTR;
typedef struct {
BYTE Protocol;
BYTE Convention;
BYTE pATRmode;
BYTE F;
BYTE D;
BYTE N;
BYTE IFSC;
BYTE IFSD;
BYTE CWT;
BYTE BWT;
BYTE ProgVoltage;
BYTE ProgCurrent;
BYTE ClockStop;
BYTE Class;
} SCR_ICC_PARAMS;
typedef struct
{
BYTE RequestBuffer[256];
DWORD RequestLength; // no of bytes in request buffer
BYTE ReplyBuffer[256];
DWORD ReplyLength; // no of bytes in reply buffer
SCR_ICC_PARAMS iccParams;
SCR_SCR_ATTR ScrAttr;
} SCR_SCR_PARAMS;
typedef struct {
BYTE mfKey[6];
} MF_KEY_DATA;
|
|
|
|
|
I am creating a COM component in VC++ using MFC and automation. The automation process is via the CCmdTarget class and IDispatch. The component is a wrapper for accessing a proprietary binary file which holds information pertaining to a scanning system we use. Specifically each binary file will hold information relating to a particular form setup, such as how many sheets the form has the fields which we are capturing off the form and so on (the package is called IST). A portion of the object model for the file structure is as follows:
Application (only one)
----Records (contains all the fields)
--------Fields
----Documents
--------Sheets
------------Grids (maybe OMR or OCR region on the form, and will link back to one a field)
etc..
The structure is stored on disk in the above manner, and read into structs. The way I have gone about exposing the structs is via nested objects and collections of objects (CTypedPtrArray). So as an example I have exposed the records as IRecord and IRecords, IRecords is a collection of IRecord objects. The annoying aspect of this is that each IRecord object must hold a pointer to the record structure that has been read off disk. This pointer is setup during construction of the collections after it has been read off disk, and will allow us to write back the information to disk if any changes are made.
This is all working fine (from what I can tell) however there appears to be a memory issue when the objects go into final release. It gives access violation error just before the application closes or the control passes the destructor and when using the component from VB it is giving an access violation.
So I’m just wondering whether anyone has any advice with relation to automation, and how to appropriately dispose of objects, as I’m a little confused about the difference between FinalRelease and the destructor. I am happy to send the project if required.
Thanks in advance.
|
|
|
|
|
i think we'd need to see code to make more a a judgement about what may or not be going on
cheers
Bryce
---
To paraphrase Fred Dagg - the views expressed in this post are bloody good ones.
--
Publitor, making Pubmed easy.
http://www.sohocode.com/publitor
Our kids book :The Snot Goblin
|
|
|
|
|
Thanks for the response!
How do you want me to send the code, do you wish to have a look at a snip of the code or the complete code? In case yu wish to see the whole code how can I send you the whole project?
Waiting for your kind reply.
Thanks!
|
|
|
|
|
I have been searching for a sample C++ code to show me how to read a file (attributes)version. (e.g right-click on file, version)
any help is greatly appreciated
|
|
|
|
|
|
Hi
I build a dialog-based program in vc++ 6, and add some code,it seems ok.
But when I add MS web browser control to my dialog(click "add activex controls->Microsoft web browser").Dramtically,My app even can not start up---but build is successed.What reason?
Another situation, I put a dialog in dll,and export it from my app. When the dialog not include any activx Control,it works fine,however,if add any activex control ,then you call it in you app( by pMyDlg->DoModal()),the dialog will not work(No error msg,but dialog never appear).
So how can I host a activeX in my dialog in dll and export it in my app?
Any comment will be appreciate.
|
|
|
|
|
Hi, I wrote a program with two vertical splitter windows. Now, I need to update the "LeftView" window, upon a DblClick action on the right window. I used the DblClk function to write something to pDoc, but how can I force the OnDraw on all windows.. UpdateAllViews() seem to fail.. :/
Thanks,
Michael
|
|
|
|
|
Could I get the bitmaps stored at display memory by capturing the screen ?
if not ,why?
|
|
|
|
|
huh ?
if you take a screen capture, you will have a bitmap in the clipboard.
but it will not take a snapshop of a memory bitmap ( ??? )
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Sorry,What I want to say is that:
A bitmap named "picture1" is stored at display memory and is displayed at the display.When I capture the screen ,and the bitmap received
didn't contain picture1 ,why?
if I want to capture the picture1,how?
Thanks
|
|
|
|
|
Hello,
I have a global class and it works fine when in WinMain, but in the MsgProc callback function I get "Access Violation" errors running the same methods in the class that worked fine in WinMain.
Any idea why this is? Thank you.
|
|
|
|
|
Hello,
How do I see the output of the preprocessor in Visual C++ .NET? Thank you.
|
|
|
|
|
Add the /E switch to the command line in the Project Settings, under the C/C++ -> Command Line tree item. This will output the preprocessor to stdout, which goes to the build window. Or, you can make preprocessor output go to a file by specifying "Generate Preprocessed File" under the C/C++ -> Preprocessor tree item.
Good luck!
Chris Richardson
|
|
|
|
|
I am a student TRYING very hard to learn C++! However, I am having a hard time understanding it. My teacher gave us a lab to derive a queue class from a list class using private inheritance. I have tried and tried to make my code work! I am just not having any luck. If there is anyone that can help I can send you the code that I have and maybe you can tell me what I have done wrong.
Or I will attach everything here! Following is Node.h, Node.cpp, Queue.h, Queue.cpp, List.h, List.cpp and the driver.cpp (driver program).
Node.h
//node header
#ifndef NODE_H
#define NODE_H
class Node
{
Node * next;
int data;
int CompareTo(Node &);
Node() {data=0; next = 0;}
};
#endif
Node.cpp
#include "node.h"
int Node::CompareTo(Node& n)
{
if(data < n.data)
{
return -1;
}
else if(data == n.data)
{
return 0;
}
else
return 1;
}
List.h
#ifndef LIST_H
#define LIST_H
#include "node.h"
class Queue;
class List
{
private:
Node *front;
Node* pos;
Node * FindNode(Node*, Node*);
public:
List();
List(List&);
virtual ~List();
bool IsFull();
bool IsEmpty();
void AddAtFront(Node &);
void AddAtRear(Node &);
void DeleteItem();
void Reset();
void GetNext(Node &);
void InsertBefore(Node &);
void InsertInOrder(Node &);
void FindItem(Node &, bool &);
bool EndOfList();
List& operator = (List&);
void Print();
};
#endif
List.cpp
#include "list.h"
#include "node.h"
#include <iostream>
#include <new>
#include <stdexcept>
using namespace std;
List::List()
{
pos=0;
front=0;
}
List::~List()
{
cout << "destructor called " << endl;
Node * temp;
while(front != 0)
{
temp=front->next;
cout << front->data << " ";
delete front;
front = temp;
}
cout << endl;
}
List& List::operator =(List & L)
{
if(this == &L)
return *this;
Node n;
front =0;
pos =0;
Node * temp =0;
Node * start =;
start = L.front;
while(start !=temp)
{
temp=FindNode(start,temp);
if(temp==0)
{
break;
}
AddAtFront(*temp);
}
return *this;
}
Node * List::FindNode(Node * start, Node * end)
{
Node * temp=start;
Node * test;
while(temp != end)
{
test=temp->next;
if(test == end)
{
return temp;
}
else
{
temp = test;
}
}
return end;
}
List::List(List & L)
{
Node n;
front =0;
pos = 0;
Node * temp=0;
Node * start;
start = L.front;
while(start != temp)
{
temp=FindNode(start, temp);
if(temp ==0)
{
return;
}
AddAtFront(*temp);
}
}
bool List::IsFull()
{
try
{
Node * temp = new Node();
delete temp;
return false;
}
catch (bad_alloc e)
{
return true;
}
return false;
}
bool List::IsEmpty()
{
return front ==0;
}
bool List::EndOfList()
{
if(pos == NULL)
return false;
if(pos->next==NULL)
return true;
else
return false;
}
void List::GetNext(Node & v)
{
if(IsEmpty())
{
throw "empty list";
}
if(pos==NULL)
{
pos=front;
v=*pos;
return;
}
pos=pos->next;
if(pos==NULL)
{
pos=front;
}
v=*pos;
return;
}
void List::Reset()
{
pos=NULL;
}
void List::AddAtFront(Node & v)
{
Node * nPtr;
if(!IsFull())
{
nPtr = new Node();
nPtr->next=front;
nPtr->data=v.data;
front=nPtr;
}
}
void List::AddAtRear(Node& v)
{
Node * nPtr;
if(!IsFull())
{
if(front==0)
{
AddAtFront(v);
return;
}
else
{
Node * temp;
temp=FindNode(front, 0);
if(temp==0)
{
return;
}
nPtr= new Node();
temp->next=nPtr;
nPtr->data=v.data;
}
}
}
void List::FindItem(Node &v, bool & found)
{
found=false;
if(IsEmpty())
{
return;
}
Node n;
Reset();
while(!EndOfList())
{
GetNext(n);
if(n.CompareTo(v)==0)
{
found=true;
break;
}
}
return;
}
void List::DeleteItem()
{
Node * tempPtr=0;
if(front==0)
{
return;
}
if(pos==0)
{
pos=front;
}
if(pos==front)
{
front=front->next;
delete pos;
Reset();
}
else
{
tempPtr=front;
while(tempPtr !=NULL)
{
if(tempPtr->next==pos)
{
tempPtr->next=pos->next;
delete pos;
Reset();
break;
}
else
{
tempPtr=tempPtr->next;
}
}
}
}
void List::InsertInOrder(Node &v)
{
if(front==0)
{
AddAtFront(v);
return;
}
else
{
Node vv;
Node & oldPos = pos;
Reset();
while(!EndOfList())
{
GetNext(vv);
if(v.CompareTo(vv) <= 0)
{
InsertBefore(v);
cout << " b " << v.data << " ";
pos=oldPos;
return;
}
}
AddAtRear(v);
pos=oldPos;
}
}
void List::InsertBefore(Node &v)
{
if(front==0 || pos==0 || pos==front)
{
AddAtFront(v);
return;
}
else
{
Node * temp=FindNode(front, pos);
if(temp==0)
{
throw "bad return from FindNode in InsertBefore";
}
Node * nPtr= new Node();
nPtr->data = v.data;
nPtr->next=pos;
temp->next=nPtr;
}
}
void List::Print()
{
Node * temp=FindNode(front, 0);
cout << "end value= " << temp->data << endl;
}
Queue.h
#include "list.h"
class Queue : private List
{
public:
Queue(); {}
Queue(Queue &);
~Queue() {};
bool IsFull() {return List::IsFull();}
bool IsEmpty() {return List::IsEmpty();}
void Enqueue(Node) {AddAtFront(v);}
void Dequeue(Node &) {Reset(); GetNext(v); DeleteItem();}
};
Queue.cpp
#include "queue.h"
#include "list.h"
Queue::Queue(Queue & s):List()
{
Node v;
Reset();
s.Reset();
while(!s.EndOfList())
{
s.GetNext(v);
AddAtRear(v);
}
}
Driver program
#include "list.h"
#include "queue.h"
#include "node.h"
//using namespace std;
void main()
{
Queue q;
Node n;
for(int i=0; i<20; i++)
{
n.data=i;
q.Enqueue(n);
}
cout << " finished adding data " << endl;
cout << " dequeuing data " << endl;
for(int j=0; j < 10; j++)
{
q.Dequeue(n);
cout << n.data << endl;
}
cout << endl;
Queue qq(q);
while(!q.IsEmpty())
{
qq.Dequeue(n);
count << n.data << endl;
}
cout << endl;
}
Thanks for helping me~
|
|
|
|
|
I am definitely missing something here, and I'm hoping that someone can provide an explanation about this question around XP themes. - I am using MFC, by the way.
In a nutshell, I guess I just don't really understand what all of this is doing. I know that you load up the dll, and then start calling functions like drawthemebackground and things like that. But - how is this different than the standard functionality provided in MFC?
Say I have a regular CButton on a form. If I run this on w2k or xp classic mode, it looks like the regular button that we all know and love. If I turn on a theme in XP, like the default one with the blue titlebar and rounded edged buttons, the button automatically looks like what I'd expectn in XP, with the rounded edged button, different color text when you hover, etc...
So - obviously I am missing something, but why go through all of this dll loading, calling functions, etc...when it appears that MFC is already handling this stuff? What is the benefit?
Confusedly yours,
Marcus Spitzmiller
"Why must life be so hard? Why must I fail at every attempt at masonry?" - Homer
|
|
|
|
|
Ut isn't MFC that is handling XP Themes but the Manifest file or .RC entry you add that tells Windows to use XP Themes.
I haven't used any of the drawthemexxx functions yet, but my understanding is that if you are using any of your own owner draw controls and you want them to look like XP controls then you use this stuff. Hope that helps.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
That was so rude of me....I forgot to reply.
Thanks very much for the answer - that makes sense, and makes me feel a whole lot better
Marcus Spitzmiller
"Why must life be so hard? Why must I fail at every attempt at masonry?" - Homer
|
|
|
|
|
I just got a IBM Assambly Language book, and I'm reading it now.
However, the book does not talk about how to compile the Assambly.
Can anyone write a very simple assambly inside C file, so I can
compile it in Visual Studio? If possible, can you also provide
C++ version?
Thanks.
-----------------------------
C++ without virtual functions is not OO. Programming with classes but without dynamic binding is called "object based", but not "object oriented".
|
|
|
|
|
Using the __asm keyword, as example:
__asm
{
movl eax, 123
xorl ebx, ebx
}
Or, you can put __asm on each assembly instruction:
__asm add esi, 0x5
__asm mov push ecx
Regards,
Michael
|
|
|
|
|
how to know if computer is connected to the internet programmatically?
includeh10
|
|
|
|
|
|
i think this api will help --->InternetGetConnectedState
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Hello!
I have a dialog-based application. The main dialogs shows another dialog before showing itself (think of a login dialog before the main dialog). Now my problem is that the login dialog isn't shown in the taskbar, only the main window shows up when you have logged in.
The dialog has caption, system menu, format: context menu, border: dialog border, 3D view, visible, no fail create, centered.
Now the question: how do I show up the first dialog in the taskbar??
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
I assume the app dialog is hidden until they login. Have a look at http://www.codeproject.com/shell/systemtray.asp[^] Functions there like CSystemTray::RemoveTaskbarIcon() may provide some clues.
Another thing to try is to make the login dialog a top level window, then it should appear in the task bar.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|