what's wrong?

S

Shark

What could be the error??

i have a dll for converting vox files to Dll.

the structure of the header looks like :

-----------------------------------------code-------------------------------------------

typedef struct tFILECONVERT
{
long lStructSize; // the size of this structure
BOOL bCallback; // if TRUE, notify the callback window after
conversion (ID + result code)
HWND hCallbackWindow; // the handle of the callback window if
bCallback is true
long CallbackID; // User provided ID used to mark the callback
message
LPSTR szInputFile; // path and name of the input sound file
WORD wInputFormat; // sound format of the input sound file
DWORD dwInputRate; // sample rate of the input sound file
WORD wInputChannels; // number of channels of the input sound file
LPSTR szOutputFile; // path and name of the output sound file
WORD wOutputFormat; // sound format of the output sound file
DWORD dwOutputRate; // sample rate of the output sound file
WORD wOutputChannels; // number of channels of the output sound file->
currently = 1
BOOL bFilter; // if TRUE, enables filtering during conversion
WORD FilterType; // filter type, if filtering is enabled
DWORD LopassCutoff; // cutoff frequency for low pass filtering
DWORD HipassCutoff; // cutoff frequency for high pass filtering
BOOL bSilence; // if TRUE, performs automatic leader/trailer
trimming during conversion
float SilenceVal; // sound intensity (in % full scale) under which
sound is considered as silence
DWORD LeaderLength; // wanted duration of the trimmed leader
DWORD TrailerLength; // wanted duration of the trimmed trailer
BOOL bNormalize; // if TRUE, allows amplification of the sound
float NormalizeVal; // intensity at which the sound should be
amplified (in % full scale)
BOOL bClarity; // if TRUE, applies sound enhancement effects during
conversion
short ClarityVal; // type of sound enhancement desired
BOOL bCenter; // if TRUE, sound will be centered around 0 during
conversion
BOOL bOldWaveFormat; // if TRUE, will generate old win3.1 wave formats
(no WAVEFORMATEX, no fact chunk)
BOOL bLogIt; // if TRUE, the conversion results will be logged in a
file
LPSTR szLogFile; // path and name of the conversion log file
BOOL bErrorMessage; // if TRUE, a litteral error message will be
returned after conversion
LPSTR szErrorMessage; // address of the string to return the error
message (must be >= 128 char)
WORD ReturnCode; // code to notify the user of the result of the
conversion
DWORD Reserved; // reserved for future extensions-> MUST be set to 0
} FILECONVERT,*PFILECONVERT,far *LPFILECONVERT;

extern "C" BOOL VoxFileConvert(LPFILECONVERT); // the actual
conversion function declaration
extern "C" void VoxConvertRegister(void); // the actual conversion
function declaration
-----------------------------------------------code
end-----------------------------------------------------------------
Now when i try to call the "voxFileConvert" function, it fails. i link
the Dll with the corresponding .Lib file,
but i tried dynamic loading also. that too fails.

-------------------------------------------code------------------------------------------------------------------------------
CONVERT()

{
LPFILECONVERT lpFileConvert;

HGLOBAL hFileConvert;
char szInputFile[256];
char szOutputFile[256];
char szLogFile[256];
char szErrorMessage[256];

hFileConvert = GlobalAlloc(GHND,sizeof(FILECONVERT));


if (!hFileConvert)
{
cout<<"Not enough memory left";
//break;
}

lpFileConvert = (LPFILECONVERT)GlobalLock (hFileConvert);

/*Upon reaching here, Access violation Error found while,(only) in
debugging mode., but when you run the program, it goes till the end ..
(till voxFileConvert).. and throws "illegal Operation" error.*/

lpFileConvert->lStructSize = 128;
lpFileConvert->bCallback = FALSE;
lpFileConvert->hCallbackWindow = NULL;
lpFileConvert->CallbackID = 0;
strcpy(szInputFile,"11.vox");
printf("%s","HAPPEND");
lpFileConvert->szInputFile = szInputFile;
printf("%s",lpFileConvert->szInputFile);
lpFileConvert->wInputFormat = SID_WAVE;
lpFileConvert->dwInputRate = 0;
lpFileConvert->wInputChannels = 0;
strcpy(szOutputFile,"11.wav");
printf("%s","HAPPEND");
lpFileConvert->szOutputFile = szOutputFile;
lpFileConvert->wOutputFormat = SID_DIALADPCM;
lpFileConvert->dwOutputRate = 8000;
lpFileConvert->wOutputChannels = 1;
lpFileConvert->bFilter = FALSE;
lpFileConvert->FilterType = 0;
lpFileConvert->LopassCutoff = 0;
lpFileConvert->HipassCutoff = 0;
lpFileConvert->bSilence = FALSE;
lpFileConvert->SilenceVal = 5.0;
lpFileConvert->LeaderLength = 50;
lpFileConvert->TrailerLength = 50;
lpFileConvert->bNormalize = FALSE;
lpFileConvert->NormalizeVal = 75.0;
lpFileConvert->bClarity = FALSE;
lpFileConvert->ClarityVal = 5;
lpFileConvert->bCenter = FALSE;
lpFileConvert->bOldWaveFormat = FALSE;
lpFileConvert->bLogIt = FALSE;
strcpy(szLogFile,"VOXlog.txt");
printf("%s","HAPPEND");
///// szIniPath );
//strcat(szLogFile,"VCLog.txt");
strcpy(szErrorMessage,"My Error");
lpFileConvert->szLogFile = szLogFile;
lpFileConvert->bErrorMessage = TRUE;
lpFileConvert->szErrorMessage = szErrorMessage;
GlobalUnlock(hFileConvert);

printf("%s","HAPPEND END");


// VoxFileConvert(&lpFileConvert); ///////////VoxDllTest has
encountered a problem and needs to close.
sprintf("CODE:","%d",lpFileConvert->ReturnCode);

--------------------------------------code
end--------------------------------------------------------------
 
M

mlimber

Shark wrote:
[snip]
Now when i try to call the "voxFileConvert" function, it fails. i link
the Dll with the corresponding .Lib file,
but i tried dynamic loading also. that too fails.

If you suspect there's a problem with static vs. dynamic loading,
you'll want to ask in Microsoft newsgroup. See this FAQ for some groups
you could post to:

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9
CONVERT()

{
LPFILECONVERT lpFileConvert;

HGLOBAL hFileConvert;
char szInputFile[256];
char szOutputFile[256];
char szLogFile[256];
char szErrorMessage[256];

This is C-style, not C++. Don't declare variables until you can
initialize and use them.
hFileConvert = GlobalAlloc(GHND,sizeof(FILECONVERT));


if (!hFileConvert)
{
cout<<"Not enough memory left";
//break;
}

lpFileConvert = (LPFILECONVERT)GlobalLock (hFileConvert);

/*Upon reaching here, Access violation Error found while,(only) in
debugging mode., but when you run the program, it goes till the end ..
(till voxFileConvert).. and throws "illegal Operation" error.*/

Do you mean the previous line causes an access violation or does the
next line? If the next, are you sure lpFileConvert points to a valid
structure? IOW, did the call to GlobalLock succeed? (BTW, if you have
questions about GlobalLock, you'll also want to post to an OS-specific
newsgroup.)
lpFileConvert->lStructSize = 128;
lpFileConvert->bCallback = FALSE;
lpFileConvert->hCallbackWindow = NULL;
lpFileConvert->CallbackID = 0;
strcpy(szInputFile,"11.vox");
printf("%s","HAPPEND");

You could just do:

printf("HAPPEND");

But why do you use printf here and cerr above? You can mix them, but
it's better to pick one and stick with it for the sake of readability
and consistency. As for which one to pick, *printf are not typesafe,
whereas iostreams are.
lpFileConvert->szInputFile = szInputFile;
printf("%s",lpFileConvert->szInputFile);
lpFileConvert->wInputFormat = SID_WAVE;
lpFileConvert->dwInputRate = 0;
lpFileConvert->wInputChannels = 0;
strcpy(szOutputFile,"11.wav");
printf("%s","HAPPEND");
lpFileConvert->szOutputFile = szOutputFile;
lpFileConvert->wOutputFormat = SID_DIALADPCM;
lpFileConvert->dwOutputRate = 8000;
lpFileConvert->wOutputChannels = 1;
lpFileConvert->bFilter = FALSE;
lpFileConvert->FilterType = 0;
lpFileConvert->LopassCutoff = 0;
lpFileConvert->HipassCutoff = 0;
lpFileConvert->bSilence = FALSE;
lpFileConvert->SilenceVal = 5.0;
lpFileConvert->LeaderLength = 50;
lpFileConvert->TrailerLength = 50;
lpFileConvert->bNormalize = FALSE;
lpFileConvert->NormalizeVal = 75.0;
lpFileConvert->bClarity = FALSE;
lpFileConvert->ClarityVal = 5;
lpFileConvert->bCenter = FALSE;
lpFileConvert->bOldWaveFormat = FALSE;
lpFileConvert->bLogIt = FALSE;
strcpy(szLogFile,"VOXlog.txt");
printf("%s","HAPPEND");
///// szIniPath );
//strcat(szLogFile,"VCLog.txt");
strcpy(szErrorMessage,"My Error");
lpFileConvert->szLogFile = szLogFile;
lpFileConvert->bErrorMessage = TRUE;
lpFileConvert->szErrorMessage = szErrorMessage;
GlobalUnlock(hFileConvert);

printf("%s","HAPPEND END");


// VoxFileConvert(&lpFileConvert); ///////////VoxDllTest has
encountered a problem and needs to close.
sprintf("CODE:","%d",lpFileConvert->ReturnCode);

This line is bad news. You're writing into a constant string!

Cheers! --M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top