|
These are both very popular and free. The Nullsoft installer includes full source code.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hi. I have a class that is responsible for opening, closing, and doing everything for a wave device (wave in only). It is derived from CWinThread, and I have the callbacks for the wave device send thread messages to it. The messages are WM_WIM_CLOSE, WM_WIM_OPEN, and WM_WIM_DATA. In the WM_WIM_CLOSE message handler, I want the thread to quit, so I have a call to ::PostQuitMessage (0). This works the first few times I open and close a wave device, but then the debugger breaks and says in the output "HEAP[recorder.exe]: HEAP: Free Heap block 151338 modified at 151358 after it was freed". Why would it be doing this? Any ideas?
Another problem: Sometimes (not always), I get similar symptons when the device in opened, only it breaks when I call ::waveInOpen (). Same type of error in the output. I can continue the program and it doesn't seem to be huring anything, but it still concerns me and is anoying when I run the program in debug mode because it always stops. Has anyone ever experienced these problems? Thanks in advance.
|
|
|
|
|
drummer wrote:
Free Heap block 151338 modified at 151358 after it was freed
The CRT is catching a bug in your code. That message means that you allocated some memory, then later freed it, then wrote to the memory again using an old pointer that was still pointing at that block.
--Mike--
My really out-of-date homepage
Buffy's on. Gotta go, bye!
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
I figured it out. I wasn't doing any cross-thread syncronization, but I added it now using CMutex's and CSingleLock's. Now it works fine. Thanks though.
|
|
|
|
|
In my Non-MFC application i need to use strtok, now i used it in another function and it works fine, but in one function it fails and I don't know why.
Here is the code from the function that works:
int fsConsole::ParseCommandLine(char* line)
{
char* funcname;
char* values;
funcname = strtok(line," ");
values = strtok(NULL, "\n");
return Execute(funcname, values);
}
Now here is the broken function:
int fsConfigManager::CreateSetting(char* settingName, void* value)
{
char* pComponent = strtok(settingName, ":");
if (pComponent == NULL)
return EFS_INVALID;
char* pSetting = strtok(NULL, "\n");
if (pSetting == NULL)
return EFS_INVALID;
ConfigList.insert(pair<char*, fsItem>(pComponent, fsItem(settingName, (char*)value)));
return EFS_OK;
}
When strtok is called in the second function i get an access violation.
Thanks in advance.
Stephen Caldwell
Blackfission, CEO
http://blackfission.myip.org:81
|
|
|
|
|
strtok() modifies its argument (by inserting '\0's to separate tokens). In the broken function, settingName has been modified and is being passed to fsItem(), which likely expects it to be unmodified.
In general, you should use strtok() with a copy of your original string.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Thank you. It worked.
Stephen Caldwell
Blackfission, CEO
http://blackfission.myip.org:81
|
|
|
|
|
I'm relativly new to MFC and would like to write some test code using the MSComm control. I've added one to my dialog and attached a variable to it. I just cannot seem to get the SetOutput() to actually output any bytes. Also, I ran across some "supposidly" working MFC code, but it will not work for me. Could someone please provide a simple example of sending a byte, say 0x90? Here is the "non-working" code that I found:
m_objMSComm.SetRThreshold(1);
m_objMSComm.SetRTSEnable(TRUE);
m_objMSComm.SetSettings("9600,n,8,1");
m_objMSComm.SetSThreshold(1);
m_objMSComm.SetPortOpen(TRUE);
COleSafeArray objOutputBuffer;
int iLoopVar=0;
long iArraySizeInc=0;
BYTE bOutput;
// First Byte to be send
bOutput='A';
objOutputBuffer.PutElement(&iArraySizeInc,(void *) &bOutput);
objOutputBuffer.ResizeOneDim(iArraySizeInc+2);
iArraySizeInc++;
// Secondt Byte to be send
bOutput='B';
objOutputBuffer.PutElement(&iArraySizeInc,(void *) &bOutput);
objOutputBuffer.ResizeOneDim(iArraySizeInc+2);
iArraySizeInc++;
// Third Byte to be send
bOutput='C';
objOutputBuffer.PutElement(&iArraySizeInc,(void *) &bOutput);
objOutputBuffer.ResizeOneDim(iArraySizeInc+2);
iArraySizeInc++;
//sending "ABC" through comm port #1
m_objMSComm.SetOutput((VARIANT)objOutputBuffer);
Thanks in advance!
|
|
|
|
|
I'm trying to write a program that will , on starting, look for a file in the root directory of the CD drive. Of course we all have different CD drive letters so how can i get the software to find the required file?
.NET or not .NET? MFC is the question......
|
|
|
|
|
GetLogicalDriveStrings() will return a list of all drive letters on the system. Pass each one to GetDriveType() until you find a CD drive.
--Mike--
My really out-of-date homepage
Buffy's on. Gotta go, bye!
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
Hi.
I am working on an interesting and simple problem. A program I am working on initializes an ofstream object. It does calculations (arbitrary) and writes to the output file. The problem is sometimes it writes new data and sometimes it does not. I am currently using a bool to make sure if it does not write new data, then it should remove the output file when it finishes. There is one false assumption. I am assuming the output file is always empty. That is not true because the output file is openned with "ios::app," which is appending mode. The program sometimes remove files that are not empty.
I tried using the empty() function, but it does not work for an ofstream object. I would like to know the best way to check to make sure an ofstream object is *empty* return from the a end of class or before the program closes.
Thanks,
Kuphryn
|
|
|
|
|
Have you tried not opening the file until you write to it ?
Crivo
Automated Credit Assessment
|
|
|
|
|
Thanks.
You made a good point. The way I designed program have it open the output file first. I feel it is more elegant relative to the *user* if I leave the program in its current structure.
I implemented the seekp() and tellg() functions determine whether the program made any changes to the output file.
Kuphryn
|
|
|
|
|
Hi.
I have a series of
char* XX[2] = {"Hi", "Hi there"};
....
These are meant to hold txt so that I can change them as a SET by changing the index.
I have a header file to hold these. My question is that I include this file in all my other classes and such that it can use this. Do I have to use extern on all these declarations in those files or another header file? I would only want to change the text in one place and not have this file and another one identical to this except with extern in front of everything. Is this right? I am not too familiar with externs but is this the only way?
If I am not correct, can someone correct me on how to use an index or some way to choose the text but to set it globally I guess so that I can use it in ANY FILE.
Thanks in advance.
|
|
|
|
|
extern tells the compiler "this is what the variable looks like".
use it like this:
code.h
------
extern int myInt; // this just tells other code that "myInt" is an int, not where it lives (ie. it's address)
code1.cpp
------
int myInt; // this allocates the variable
code2.cpp
------
#include "code.h"
myInt = 5; // use it
-c
Smaller Animals Software, Inc.
|
|
|
|
|
For
char* Text[2] = {"hi","hi there"};
THe extern statement would be
extern char* Text[2];
Is this correct?
|
|
|
|
|
|
I like to keep these kinds of things all in one file. Here is a couple of macros that help with doing this.
// in YourHeader.h
#ifdef MAIN
#define Global
#else
#define Global extern
#endif
// if not initializing
Global char *XX[2];
// if you are going to initialize it do this :
#ifdef MAIN
char *YY[2] = { "String 1", "String 2" };
#else
extern char *YY[2];
#endif
// in your source code files
// do this one and only one time
#define MAIN
#include "YourHeader.h"
// no other source files may contain the MAIN definition
|
|
|
|
|
Somewhat of an aside, but globals are of the devil, if you must use them, you should put them into a namespace.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Ewww, I bet you think gotos are the spawn of Satan.
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
But of course.
NumberOfTimesIHaveUsedGotoInC = 0;
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
As a very "general" rule, you should try to avoid declaring variables in a header file, simply because every source file that includes them will re-create that variable's declaration. If you really want a global variable, you should declare it in a source file, and then when another source file needs to access or update it, declare it again in that source file using extern. Extern says "There is a variable (with memory allocated) somewhere else in the program and it looks like this." Separating your global variables like this helps to keep track of them, because you declare them in the source file where they are "owned," and then use extern for everywhere else where they are "used."
While various macros have been developed for use in header files to optionally compile or not compile the extern for variables, this is really just a confusing trick to get the compiler to do what I have described. It's only confusing to you and other programmers, because you still have to find when the original file is to find if the macro #define is made in order to get the original variable declaration.
Dave
"You can say that again." -- Department of Redundancy Department
|
|
|
|
|
I am trying to write a program that has an SDI interface, but has three tabs within that. Does anyone know where i can get the code for this, i have checked out the samples on this site and www.codeguru.com, but none of them use a tabbed interface.
==================================================
When Your Mind Wonders...Where Does It Go???
|
|
|
|
|
Hello,
How to write a WinNT service by VC, I read MSDN, it seems use ATL,
but I can't understand clearly, have some kindly give me an example ??
please email to vistac@ms10.hinet.net
Thanks.....
Vistac Wu
|
|
|
|
|
did you try looking on this site first? there are many articles on services here. http://www.codeproject.com/system/
-c
Smaller Animals Software, Inc.
|
|
|
|