|
Try _chmod
if( _chmod( "CHMOD.C", _S_IREAD ) == -1 )
perror( "File not found\n" );
else
printf( "Mode changed to read-only\n" );
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
One solution is SetFileAttributes().
Kuphryn
|
|
|
|
|
Hi,
I would like to enable / disable a NIC adapter from a user program. The driver is installed previously. Can someone point me to any function which can do that ?
I already have a working PassThru driver which to do some operations on the card.
Thanks !
Jayanta
|
|
|
|
|
hi,
Clipcursor is not working in XP.
RECT rcClip; // new area for ClipCursor
RECT rcOldClip; // previous area for ClipCursor
// Record the area in which the cursor can move.
GetClipCursor(&rcOldClip);
// Get the dimensions of the application's window.
GetWindowRect(&rcClip);
// Confine the cursor to the application's window.
ClipCursor(&rcClip);
// Process
....................
// Restore the cursor to its previous area.
ClipCursor(&rcOldClip);
whats wrong ?
regards
hari
Hari Krishnan
|
|
|
|
|
I'm a recent cs graduate and studied MFC programming as an undergrad, and I'm curious to ask what is the future of MFC with the arrival of .NET? and what about COM as well? The reason i ask is whether i should invest the time in learning .NET. Your input would be greatly appreciated.
|
|
|
|
|
hi,
there is no threat to MFC in the near future. .NET will take some time to catch up.
There are some excellent articles in the 'Interview' section of codeproject that will answer this.
Hari Krishnan
|
|
|
|
|
|
Save.cpp is a file in my VC program, but after my system's reboot which is caused by one systems' exception, this file is covert to a binary file, when I open the file, system prompt
"this file is bianry and cannot be read "
000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00…………
000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00…………
000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00…………
........
I want to know how to get back my CPP File?
Thanks!
Just do it !
|
|
|
|
|
|
|
In VC6, in the File Open dialog, use the 'Open as' dropdown list and select 'Binary'.
In VS.NET, in the File Open dialog, click on the dropdown attached to the Open button and select Open With... Select Binary Editor from the list.
In either case, this will open the file in the IDE's binary editor, which lets you change the file contents in hex. Use this to examine and correct the problems in the file.
Good luck.
Software Zen: delete this;
|
|
|
|
|
Where Coudle I Get IDE's binary editor?
Thanks
Just do it !
|
|
|
|
|
Hello all.
I am fairly new to programming with Visual C++. I am currently using version 6.0. I have done a lot of work in VB in the past, and am trying to migrate over to VC.
I am wondering if someone can point me in the right direction here. I am just tinkering around at this point. I've got an MFC program, with a listbox. I found some code and modified it for my liking. It's just simple code that searches the c:\ drive for all files and folders. If it finds a folder, it searches that folder too. It adds all of the files/folders to the listbox (m_ListBox.AddString()) is what I'm using. I'm also doing an m_ListBox.UpdateWindow() after each addition to ensure the window shows the contents correctly.
The problem I am running into is that since there are so many files on the C: drive, it takes a long time for the program to find them all. It adds the items very fast to the listbox, but what is happening is it is "locking up" the program (so to speak). Not Responding will show up on the window title, and it does not allow me to go into the listbox and click on the UP/DOWN arrows to scroll through while it is working.
In VB, I would use the function "DoEvents" and that would cause the program to let other things happen meanwhile. I am wondering how I would go about doing this in VC+?
Any pointers or hints or links to some documents that may be able to help me would be very much appreciated.
-Shultas
|
|
|
|
|
You will have to create a worker thread via CreateThread and find files in that thread and then send a WM_USER message from that thread to ur window which will eventually add items in the list control
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
|
Hi friends,
I'm going to compose a new bitmap by myself, and I'm using buffer to store up the data inside bitmap. But I did it wrong, and I get conflicts on that. can somebody help me and teach me how to store up correct contents in buffer??
I just want to draw a black "cross" on the center of bitmap with (1024x1024 pixel)
unsigned char *mBuffer = NULL;
int i;
int mByte = 1024/8;
int mWidth = 1024;
int mHeight = 1024;
for(i=1; i<=mHeight; i++)
{
if(i< mHeight/2)
{
memset(mBuffer+(i*(mWidth/2)), 0xff, 1);
}
else if(i==mHeight/2)
{
memset(mBuffer+(i*(mWidth)), 0xff, mByte);
}
else
{
memset(mBuffer+(i*(mWidth/2)), 0xff, 1);
}
}
forgive my stupid~, I really don't know how to store up the buffer..
thanks for help
|
|
|
|
|
Forget the buffer appoarch!
Creating for latter use:
1) Create a display compatible device context (memory DC).
2) Create a compatible bitmap of the size needed.
3) Select the bitmap into the device context.
4) Use GDI to draw the cross on the bitmap.
5) Select the previous bitmap into the device contest.
6) Delete compatible device context.
If you are keeping a copy of the bitmap for latter use, then you are all set.
In OnDraw():
1) Create compatible device context (memory DC).
2) Select bitmap into DC.
3) Blit to window.
4) Select previous bitmap into DC.
5) Delete compatible DC.
If you do not need to keep a copy of the bitmap.
In OnDraw():
1) Create a display compatible device context (memory DC).
2) Create a compatible bitmap of the size needed.
3) Select the bitmap into the device context.
4) Use GDI to draw the cross on the bitmap.
5) Blit to window.
6) Select the previous bitmap into the device contest.
7) Delete compatible device context.
INTP
|
|
|
|
|
Hi
Any one have any ideas on how to determine the size of a directory and any subsirectories?
I tried creating a console application using the _findfirst()/_findnext() functions. I think there must be an easier way.
Thanks in advance for any sugestions/comments.
|
|
|
|
|
Yes! But I would have to do the same reseach you need to. By the looks of it you may have already determine there is more than one way to do it. There are articles at codeproject and elswhere on this subject and there may be something in the FAQ. Try keywords: searching, directory, CFile, find. You also might try searching for passed questions posted, as simular questions have been asked before.
INTP
|
|
|
|
|
When I overide the CWinapp::Run, and drag the toolbar from the Mainframe window, I noticed the mainframe area where the toolbar was does not update. It leaves a blank area. Any ideas?
Thanks
|
|
|
|
|
ok i have very strange problem in first case everything is ok
<br />
int (*handler[15])(int parm); <br />
int user_trans_quit(int parm); <br />
<br />
int user_trans_quit(int parm){ <br />
printf("Just a test %d", parm); <br />
return 0; <br />
} <br />
int _tmain(int argc, _TCHAR* argv[]) <br />
{ <br />
handler[1]=user_trans_quit; <br />
handler[1](1); <br />
} <br />
but when i try to meke OO compiler give me this error "error C2064: term does not evaluate to a function taking 1 arguments"
<br />
#pragma once <br />
class PacketHandler <br />
{ <br />
private : <br />
<br />
public: <br />
PacketHandler(void); <br />
~PacketHandler(void); <br />
int LoginAck(char *parm); <br />
void Action(int i, char *data); <br />
int (PacketHandler::*handler[255])(char *parm); <br />
}; <br />
.... <br />
#include "StdAfx.h" <br />
#include ".\packethandler.h" <br />
<br />
PacketHandler::PacketHandler(void) <br />
{ <br />
handler[1]=LoginAck; <br />
} <br />
<br />
PacketHandler::~PacketHandler(void) <br />
{ <br />
} <br />
int PacketHandler::LoginAck(char *parm) <br />
{ <br />
return 0; <br />
} <br />
void PacketHandler::Action(int i, char *data) <br />
{ <br />
handler[i](data);
} <br />
10x in advance
PS:sry about my bad english
|
|
|
|
|
TRY...
define "LoginAck" as a static function
I am seeking...
For what?
Why did you ask me for what? I don't know!
|
|
|
|
|
|
I think XSimon is correct about making LoginAck() static. You also need to forward declare your class type "class PacketHandler". Of cource I understand this is only a sample, so the lack of a contructor I am ignoring. The line "handler[1]=LoginAck;" gives the impression you are thinking that the array starts at 1, it does not, the range is 0 to 254. If you want 0 - 255 use 256 instead of 255 in your declaration.
Considering where the error occurs, you probably need to declare "int (PacketHandler::*handler[255])(char *parm);" as static.
God luck!
INTP
|
|
|
|
|
found the problem 10x alot
i must call function in this way (this->*handler[i])(data);
.. dont know way its look totaly stuped for me .. but its work
10x for the help
|
|
|
|