|
wb = open new binary file for writing, if file exists with same name, it will be truncated to 0 bytes
ab = open new binary file for writing, if file exists with same name, new data would be written at end of file. This may lead to undesired results if file already exists.
you should check if a file exists before opening it in wb mode :
#include<stdlib.h>
#include<stdio.h>
#define MAX 1024
int main(int argc,int **argv){
FILE *fsource,*fdest;
size_t in;
int buf[MAX];
char c = 'n';
fsource = fopen("F:\\a.jpg.rar","rb");
fdest = fopen("D:\\a.jpg","r");
if(fdest!=NULL){
fclose(fdest);
printf("Destination file already exists, do you want to overwrite?\t");
scanf("%c",&c);
if(c!='Y' && c!='y'){
fclose(fSource);
return 1;
}
}
fdest = fopen("D:\\a.jpg","wb");
if(fsource == NULL || fdest == NULL)
perror("open error");
while((in = fread(buf,sizeof(int),MAX,fsource)) != 0){
fwrite(buf,sizeof(int),in,fdest);
fflush(fdest);
}
fclose(fsource);
fclose(fdest);
return EXIT_SUCCESS;
}
|
|
|
|
|
while(IsCapture)
{
pcap_loop(adhandle, 1, packet_handler, NULL);//call this function
}
void CIPv6_packet_analyzerView::packet_handler(u_char* param, const struct pcap_pkthdr* header, const u_char* pkt_data)
{
//================definition
}
error when compile:
error C3867: 'CIPv6_packet_analyzerView::packet_handler': function call missing argument list; use '&CIPv6_packet_analyzerView::packet_handler' to create a pointer to member
what's wrong? this program can run in vc6.0
use '&CIPv6_packet_analyzerView::packet_handler' to create a pointer to member
while(IsCapture)
{
pcap_loop(adhandle, 1, &CIPv6_packet_analyzerView::packet_handler, NULL);
}
error when compile: :error C2664: 'pcap_loop' : cannot convert parameter 3 from 'void (__thiscall CIPv6_packet_analyzerView::* )(u_char *,const pcap_pkthdr *,const u_char *)' to 'pcap_handler'
Thank you very much
|
|
|
|
|
the VC6 installation error happended several times when I install it:
Setup was unable to create a DCOM user account in order to register "c:\Program Files\Microsoft\Visual Studio\Common\Tools\VS-Ent98\Vanalyzr\Valec.exe"
At last of installation process, setup said: failed.
But VC6 still can be used .
BTW: When try to update VC6 with service pack, service pack setup says: Can not find any VC products.
What is the problem? how to fix it?
|
|
|
|
|
|
google it. The answer is the first result.
|
|
|
|
|
Hi,
I want to change the shape and color of a MFC dialog box?
Any feedback on this would be appreciated. I know this is probably a very common
question, just dont know how to do this.
Much appreciated,
garyc
|
|
|
|
|
A window is always rectangular.
Any other shape can be created using a region.
There are several functions in GDI that help you create regions - Region Functions[^]
Here is a simple example with source code to create a region from a bitmap and apply to a window.
Fish Region[^]
Background color can be set by handling the WM_CTLCOLORDLG[^] message.
|
|
|
|
|
Much appreciated.
I never knew how they did this and now I know.
Thanks,
Garyc
|
|
|
|
|
you can add this with ClassWizard,or in the sources code to add it by yourself.
just like this:
C***Dlg.h
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
C***Dlg.cpp
BEGIN_MESSAGE_MAP
......
ON_WM_CTLCOLOR()
......
END_MESSAGE_MAP()
HBRUSH C***Dlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
switch (pWnd->GetDlgCtrlID())
{
case IDC_STATIC1:
case IDC_STATIC2:
pDC->SetTextColor(RGB(255,0,0));
break;
case IDC_STATIC3:
case IDC_STATIC4:
pDC->SetTextColor(RGB(0,0,255));
break;
}
return hbr;
}
Best Reguards !
by Koma
http://blog.csdn.net/wangningyu
|
|
|
|
|
Much apreciated guys for your contributions.
Thanks,
Garyc
|
|
|
|
|
Hi,
I need help to write a multi thread simple class,
I know this should be simple but I face some difficulties,
any help will be appreciated.
Implementing single-write, multiple-read multi thread synchronization (using windows synchronization primitives like mutex, semaphore etc.).
Thanks in advance,
Eyal
modified on Saturday, October 17, 2009 7:11 AM
|
|
|
|
|
Hi Eyal!
In what problem did you run, what have you done so far, which multithreading tutorials have you read?
Have a good weekend
/M
|
|
|
|
|
Hi Moak,
Just faced with this question in a C++ questioner/quiz.
I read information/tutorials on multithreading mutex but I haven't deal yet with the answer.
looking for the right answer.
Best,
Eyal
|
|
|
|
|
|
cmk,
Thank you very much,
Eyal
|
|
|
|
|
The code I'm using needs HWND but I just have no clue how it works and how to initialise it.
In my SoundManager class I have:
bool OggPlayer::InitDirectSound( HWND hWnd )
{
//code
}
and then in mainGame:
void MainGame::Initialise()
{
HWND hwnd = NULL;
op.InitDirectSound(hwnd);
op.OpenOgg("music.ogg");
op.Play();
//random code
}
Obviously I need to pass hwnd into InitDirectSound but at this point I'm just guessing and setting it to null.
Any help explained in layman's terms would be appreciated.
|
|
|
|
|
What kind of application have you built?
Is it an MFC application?
If it is you can get the main application window handle using AfxGetMainWnd()->m_hWnd .
If it is a dialog application and your writing the code in the dialog class, you can directly use m_hWnd .
|
|
|
|
|
No MFC involved.
I'll try using m_hWnd... when I figure out how to use it >_>
|
|
|
|
|
GLGunblade wrote: I'll try using m_hWnd... when I figure out how to use it >_>
This is just the handle to your application's main window (whether app, or dialog). Windows needs it to discover who makes the call to an API function. You don't need to figure out how to use it so much as use the value that is returned by a CreateWindow() call, or in a Dialog application the handle that Windows sends you on every callback.
|
|
|
|
|
Sorry but still stuck, I'm pretty much a n00b programmer.
By using it I mean I just have no clue on handles or what not or where to put m_hWnd, it comes up as undeclared identifier. Everytime I've coded I've never really bothered with this and if some piece of code included it i just stuck it in and hoped it worked.
I have no CreateWindow call and I have no idea where in my program (which isn't really my program) windows sends a handle.
|
|
|
|
|
GLGunblade wrote: which isn't really my program
Cannot ask the author?
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]
|
|
|
|
|
He wasn't available at the time and since I wanted this done asap and wasn't probably wouldn't see him till Tuesday i thought i'd ask.
Though I've got it working. Thanks for the help guys
|
|
|
|
|
GLGunblade wrote: I have no CreateWindow call and I have no idea where in my program (which isn't really my program) windows sends a handle.
I would suggest that you get hold of a book on Windows programming to get an understanding of the basics; Charles Petzold has written some very good ones.
|
|
|
|
|
i'll keep that in mind and take a look, thanks
|
|
|
|
|
Hi,
I am wondering if any of the experts can give me some insights into the Different behavior
of the RichEdit when the object is Connected
By DDX_CONTROL as opposed to Create
1) The Font is Different
2) GetTextExtent for calculating the Length
of a line works differently (maybe
this has to do with font)
3) The Background Color is different
with DDX_CONTROL it seems be in
reverse video (when I right
it goes away)
thankx
|
|
|
|