|
Hi,
includeh10 wrote: typedef struct _ABC
{
//....
}ABC;
how to undef ABC here?
The Short answer is: Cannot be Done! To ask the question in the first place shows a lack of understanding on how the various pieces of the jigsaw are fitted together when you build an application. This is a vast subject, which cannot be adequately covered in this answer. However, the following is a short answer.
The Headerfiles in general do not contain code. They contain information required by the compiler, (akin to a User Manual for a library) to build modules in such a manner that the entre project can successfully link with the libraries. If you want to upgrade the horsepower of your car, you do not do so by changing the User Manual, but by changing the Engine.
So, an 'untypedef' does not exist, because it cannot serve any usefull purpose.
<blockquote class="FQ"><div class="FQA">includeh10 wrote:</div>this is for correcting/updating VC lib errors.</blockquote>
Hmm...
Well, if you must...
There is no point in changing Header Files, or 'untypedeffing' anything You must Rewrite the Libraries, using exactly the same names throughout, (The best way of doing that is using the existing header files), and save the result in your Windows/System Folder, replacing the Old and Faulty VC libraries.
Success with your Repairs/Upgrades.
Bram van Kampen
|
|
|
|
|
I wrote the code below to copy a picture,and why it will fail if i change the mode of fdest to "ab"?
"ab" means write and add to file,isn't it?what's the difference?
#include<stdlib.h>
#include<stdio.h>
#define MAX 1024
int
main(int argc,int **argv){
FILE *fsource,*fdest;
size_t in;
int buf[MAX];
fsource = fopen("F:\\a.jpg.rar","rb");
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;
}
modified on Saturday, October 17, 2009 5:49 AM
|
|
|
|
|
What do you mean by "it will fail"? The file is not readable? The function itself fails to execute?
Does the file exist while you are using the ab mode? In which case, the contents will simply be appended, and this might render the file unusable.
Dengjin_CN wrote: what's the difference?
You could refer to the table here[^]
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
thanks for your reply.
"it fails" means the file was created but was empty.I realized that the file d:\\a.jpg doesn't exist there before the program runs,now i created it then execute the program,it successed.
however,i can't understand my book says "a" will create a file when the file doesn't exist,campare with "w", why it produces different result?
|
|
|
|
|
I just tried your program and it works correctly in both cases. If you use the specification "wb" then it will always create a new file. If you use "ab" it will do the same, except if the file already exists then it will add to the existing file. For example if you write 100 bytes with "wb" your file will always be 100 bytes long. But if you write 100 with "wb" and then another 100 with "ab" it will be 200 bytes long.
|
|
|
|
|
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.
|
|
|
|
|