|
shiva shankar wrote:
plz can i get source code in c or c++ to run an batch file.
in C, or c++ (in dos mode)
call
system("c:\\yourbatch.bat");
include process.h file
I want to change Myself..Can u help me?
|
|
|
|
|
whenever a folder is renamed with extension of system folders such as recycle bin,favorites etc., the data in it gets hidden.
how can i implement this using vc++
milind
|
|
|
|
|
refer IShellChangeNotify interface
I want to change Myself..Can u help me?
|
|
|
|
|
I'm programming an application on Sun platform.I should need to get constructor information for any struct.My program defined many struct types,i want to builde a generic arithmetic to process anyone of all struct variables.Therefore i must get members and its types of struct on run time.How can i do for it? Thank you for presenting me some helps.
|
|
|
|
|
Interesting. One possible solution is a map. Another solution is dynamic casting. Derive the structure from an interface.
Kuphryn
|
|
|
|
|
Hello, seems i have a problem on terminating processes by name. I need visual C, not c++ code to terminate processes. Does anybody have this? I wonder if it's even possible because i wrote some c++ code that terminates processes by name using szName but when i did a conversion to C gave me a lot of errors. If anybody has visual C code to terminate process, PLEASE HELP ME!
Oh by the way i am looking for this api: TerminateProcess(...)
-Ryan M.
|
|
|
|
|
TerminateProcess(...)
are you looking for this api ?
God is Real, unless declared Integer.
|
|
|
|
|
Hi!
But what Jeff Richter says, TerminateProcess() doesn't give a clean exit. Instead TerminateThread() or ExitProcess() can be used. TerminateProcess() is brutal.
|
|
|
|
|
may be, or may be not, the poster was looking for TerminateProcess and thats the answer for him. and he acknowledged it.
God is Real, unless declared Integer.
|
|
|
|
|
I have the following structs defined. I ultimately want to copy UserInfo into a BYTE buffer to send to an RS232 serial port..
typedef struct {
u_32 prot_ver;
u_32 nomem_ver;
u_32 func_units;
u_32 sysType;
u_32 startupMode;
AttributeList option_list;
AttributeList supported_aprofiles;
} UserInfo;
typedef struct {
u_16 attribute_id;
u_16 length;
u_16 attribute_val;
} AVAType;
typedef struct {
u_16 count;
u_16 length;
AVAType value[1];
} AttributeList;
I have a buffer
msgBuffer = new BYTE [1000];
and i'm tryin to do
memcpy (msgBuffer, (BYTE *) &UserInfo, sizeof (UserInfo);
The first 5 fields copy, but the AttributeList struct field dont copy immediately behind the u_32 in my msgBuffer.
I basically need the 'count' field of the AttributeList immediately behind the 'StartupMode' field.
Some its not copying right. HELP?!?!?!?!??!
-C
|
|
|
|
|
Compilers may not place all members of a struct adjacent to each other; this is called packing. Depending on the CPU architecture, it may be more efficient or even required that memory accesses take place on 2 byte, 4 byte, or higher boundaries. I believe the default packing for Visual C++ is 8 bytes. This means that your struct 's will have padding between the members.
Fortunately, you can override this behavior in your code:
#pragma pack(push,1)
typedef struct {
u_32 prot_ver;
u_32 nomem_ver;
u_32 func_units;
u_32 sysType;
u_32 startupMode;
AttributeList option_list;
AttributeList supported_aprofiles;
} UserInfo;
typedef struct {
u_16 attribute_id;
u_16 length;
u_16 attribute_val;
} AVAType;
typedef struct {
u_16 count;
u_16 length;
AVAType value[1];
} AttributeList;
#pragma pack(pop) The initial pragma saves the current packing level, and then sets it to 1, which will cause all members to be adjacent, with no padding. The final pragma restores the packing level.
Software Zen: delete this;
|
|
|
|
|
I already had the the #pragma statements around my entire h-file and its still happening. Is there another setting for this??
Do I need to explicitly put it around each struct or at the beginnng of the H file sufficient?
I"m pushing and popping in every h-file that has structs defined. Thanks.
-C
|
|
|
|
|
Wheatbread wrote:
already had the the #pragma statements around my entire h-file and its still happening. Is there another setting for this??
There is a default value set using the /Zp command line option to the compiler. You can look in your project settings to see what it is.
Wheatbread wrote:
Do I need to explicitly put it around each struct or at the beginnng of the H file sufficient?
'Around each struct' is not required. The pragma pack(push,1) remains in effect until the corresponding pragma pack(pop) is encountered. Just for the sake of consistency, though, I would put the push and pop in each .H file that needed it. That way, if another .H is included in between that changes the packing level, you don't have unforseen changes taking place.
Software Zen: delete this;
|
|
|
|
|
My project settings are /Zp1. I changed structure alignment to 1 byte when I created the file.
Am I copying the struct wrong maybe? I've done this many times before and this hasnt happened.
Not sure how else to do it other than copying the AttributeList struct inside the larger struct separately, but that would SUCK!
I"ll take all suggestions here!!
-C
|
|
|
|
|
Actually I believe it is called alignment and I believe that the default behavior is to align data to the size of the item. This means a double (8 bytes) is aligned to an 8-byte boundary, four-byte items are aligned to four-byte boundaries, etc.
However, I don't have a good explanation for why the memcpy fails. I recommend inserting some trace messages to display the sizeof values to see if something looks weird. sizeof should take into account alignment issues.
__________________________________________
a two cent stamp short of going postal.
|
|
|
|
|
Print out the sizeof UserInfo. Make sure that value looks good.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
you don't read previous posts do you ?
__________________________________________
a two cent stamp short of going postal.
|
|
|
|
|
I did and at no point what this information discussed.
The problem is that you guys are off in the weeds talking about things that probably have nothing to do with the problem.
Why would memcpy fail?
Why would data be missing?
The truth is memcpy probably isn't failing and the data is missing because it wasn't there to begin with.
Chances are the data coming in isn't good and thus the data coming out is just as bad. The data being such things as the input data and the size of the data block. One of those two are bad.
memcpy doesn't fail unless you give it trash.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
The sizeof (UserInfo) would be interesting.
FWIW I ran your code in a test program and it packs properly,
#pragma pack ( push, 1 )
typedef struct {
unsigned short attribute_id;
unsigned short length;
unsigned short attribute_val;
} AVAType;
typedef struct {
unsigned short count;
unsigned short length;
AVAType value[1];
} AttributeList;
typedef struct {
unsigned prot_ver;
unsigned nomem_ver;
unsigned func_units;
unsigned sysType;
unsigned startupMode;
AttributeList option_list;
AttributeList supported_aprofiles;
} UserInfo;
#pragma pack ( pop )
int main()
{
UserInfo ui ;
ui.prot_ver = 'AAAA' ;
ui.nomem_ver = 'BBBB' ;
ui.func_units = 'CCCC' ;
ui.sysType = 'DDDD' ;
ui.startupMode = 'EEEE' ;
ui.option_list.count = 'FF' ;
ui.option_list.length = 'GG' ;
ui.option_list.value[0].attribute_id = 'HH' ;
ui.option_list.value[0].length = 'II' ;
ui.option_list.value[0].attribute_val = 'JJ' ;
ui.supported_aprofiles.count = 'KK' ;
ui.supported_aprofiles.length = 'LL' ;
ui.supported_aprofiles.value[0].attribute_id = 'MM' ;
ui.supported_aprofiles.value[0].length = 'NN' ;
ui.supported_aprofiles.value[0].attribute_val = 'OO' ;
char * msgBuffer = new char [1000];
::memset ( msgBuffer, 0, 1000 ) ;
::memcpy (msgBuffer, (char *) &ui, sizeof (UserInfo)) ;
std::cout << "UserInfo size = " << sizeof ( UserInfo ) << std::endl ;
std::cout << msgBuffer << std::endl ;
delete [] msgBuffer ;
return 0;
}
Output was
UserInfo size = 40
AAAABBBBCCCCDDDDEEEEFFGGHHIIJJKKLLMMNNOO
However it seems to me that your use of arrays of AVAType in AttributeList implies that they need to be of variable length and therefore this whole problem will be moot?
Paul
|
|
|
|
|
I'm not sure why its not working either.
The AVATypes will be variable length in the result msg that I receive. The transmitted message only have one AVAtype.
I will try checking the size of etc and see what happens and post again. Thanks.
-C
|
|
|
|
|
Please, anybody help me.
I'm a beginner in MFC.
And I'm sorry for my english if it's not good. I'm from Russia.
Now I'm making a simple database program and I'm need to provide a search mechanism for it.
Well, for instance, my general view class is CDBView and search dialog class is CSearch.
Search dialog is called by CDBView::OnSearch() function (Menu item). It's look like this:
CDBView::OnSearch()
{
CSearch dialog;
dialog.DoModal();
...
"search mechanism"
}
But I can't provide "search mechanism" by calling DoModal() in CDBView::OnSearch() and by writing
"search mechanism code" in CSearch::OnOK() (OK is the button for search in dialog). Why??? I've
got "Debug Assertion Failed ..." or something like that. What does this mean?
My search mechanism uses CRecordset m_pSet variable that also defined in CDBView class.
NOTE: search mechanism fully work if defined in CDBView class.
|
|
|
|
|
Jeez - you need to buy a book on this stuff and get up to speed. It sounds like you are in over your head. VC++ will generate a dialog for you if you specify that it is for a database, but then you must integrate that database using OBDC in the control panel. Perhaps you do not have installed Access correctly.
|
|
|
|
|
Hello everyone,
I have a pretty simple question. I am not sure if I am doing this correctly. I have created a user login dialog box. I want this dialog box to come up before my main window opens. I put the code in the constructor of my CMainFrame object. Am I doing this correctly?? Will this cause any big problems?
Thanks for all of your help.
There are 10 kinds of people in this world. Those who understand binary and those who don't.
|
|
|
|
|
what i did was have a toolbar (or menu) item that brought up the login dialog box (in case they logged out or cancelled the login or whatnot) ... at the end of the InitInstance() code send a message to urself that mimics the login button being clicked and voila the box pops up
"there is no spoon" biz stuff about me
|
|
|
|
|
That's a good idea. Didn't even think of putting it in that way. Thanks for the help Lauren.
There are 10 kinds of people in this world. Those who understand binary and those who don't.
|
|
|
|