Click here to Skip to main content
15,904,416 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: Combo box problem Pin
User 91483318-Apr-04 13:09
User 91483318-Apr-04 13:09 
Questionhow to fix this error?? Pin
don7cry14-Apr-04 16:03
don7cry14-Apr-04 16:03 
GeneralFrom managed Object* to unmanaged IUnknown Pin
Member 78199113-Apr-04 13:26
Member 78199113-Apr-04 13:26 
GeneralRe: From managed Object* to unmanaged IUnknown Pin
ian mariano25-Apr-04 14:13
ian mariano25-Apr-04 14:13 
GeneralCRC32 Pin
Member 10035669-Apr-04 20:59
Member 10035669-Apr-04 20:59 
GeneralRe: CRC32 Pin
Mikko Puonti9-Apr-04 23:15
Mikko Puonti9-Apr-04 23:15 
GeneralRe: CRC32 Pin
Anonymous10-Apr-04 4:50
Anonymous10-Apr-04 4:50 
GeneralRe: CRC32 Pin
Mikko Puonti12-Apr-04 20:24
Mikko Puonti12-Apr-04 20:24 
8) You don't declare and give value for "length". This is why you get error C2065. For example:
<code>
int main()
{
	// This causes error C2065, because compiler doesn't know 
	// identifier "x".
	int i = 100 * x; 
}
</code>

To solve problem:
<code>
int main()
{
	// Here we declare (tell compiler that identifier "x" means integer value) and 
	// define (tell compiler that identifier "x" value is 1) identifier "x"
	int x = 1;
	// Now this doesn't cause any problems, because compiler a) knows identifier x and
	// b) there is assigned value for identifier "x" (actually C++ compiler doesn't know 
	// this, and forgetting to give actuall value for identifier "x" would cause random 	// runtime behaviour a.k.a. bugs)
	int i = 100 * x; 
}
</code>


Here is one possible way to calculate length.

<code>
LONGLONG done = 0;
UINT size = BUFFERSIZE;
BYTE buffer[BUFFERSIZE];

int theFile = _tsopen(pCRCSt->FileName, _O_RDONLY | _O_SEQUENTIAL | _O_BINARY, _SH_DENYWR);
if (theFile != -1)
{ 
	// Getting file length and storing it to length value. 
	// 
	// SEEK_END sets position to the end of file. 
	// 
	// _lseek returns the offset in a 64-bit integer, in bytes, of the new position 
	// from the beginning of the file (in this case it returns length of file, 
	// because we set seek position to END OF FILE).
	// 
	long length = _lseeki64( theFile, 0L, SEEK_END );
	if( length == -1L )
	{
		// The function returns –1L to indicate an error and sets errno.

		// Avoid file processing, but close file
		size = 0L;

		// Specific error handlers
		switch( errno )
		{
			case EBADF:
				// File descriptor is invalid
				// TODO: ADD EXTRA ERROR HANDLING
				// For example: throw exception or show message box for user.
				break;
			
			case EINVAL:
				// Value for origin is invalid or the position
				// specified by offset is before the beginning of the file.
				// TODO: ADD EXTRA ERROR HANDLING
				// For example: throw exception or show message box for user.
				break;
			
			default:
				// Unknown error code				
				// TODO: ADD EXTRA ERROR HANDLING
				// For example: throw exception or show message box for user.
				break;			
		}
	}
	if( length <= 0 )
	{
		// On devices incapable of 
		// seeking (such as terminals and printers), the return value 
		// is undefined.
		length = 1L;
	}


	// Move file reading position to beginning of the file. 
	_lseeki64 (theFile, 0L, SEEK_SET); 
	while (size == BUFFERSIZE)
	{
		size = _read(theFile, buffer, BUFFERSIZE);
		if (size)
		{
			pCRCSt->pCRC_32->Calculate(buffer, size, CRC);
			if (::IsWindow(Progress))
			{
				//update progcess bar
				done += size;
				int percent = (int) (((long double)done / (long double)length) * 100); 
				::PostMessage(Progress, PBM_SETPOS, percent, 0);
			}
		} 
	} 

	// Close file (this is important. Error handlers need to make sure that this is allways called.)
	close(theFile);
} 

</code>


11) Your header file did have declaration for method called "Calculate", but I didn't see
any implementation for that code. (You declared identifier "Calculate" as method that doesn't return anything and takes three parameters, but you didn't provide code for that method (definition)).

I hope that you know what you are doing. There is ready CRC32 implementation for Managed code in .NET platform. And some some ready code for native C++. So you might not need to do this byself (unless you are trying to learn native C++).
GeneralRe: CRC32 Pin
PJ Arends18-Apr-04 14:59
professionalPJ Arends18-Apr-04 14:59 
GeneralManaged DirectX problem Pin
reznod9-Apr-04 8:59
reznod9-Apr-04 8:59 
GeneralRe: Managed DirectX problem Pin
Mikko Puonti9-Apr-04 23:18
Mikko Puonti9-Apr-04 23:18 
GeneralRe: Managed DirectX problem Pin
reznod10-Apr-04 7:04
reznod10-Apr-04 7:04 
GeneralDllImport problem Pin
reznod8-Apr-04 7:11
reznod8-Apr-04 7:11 
GeneralRe: DllImport problem Pin
Anthony_Yio13-Apr-04 0:42
Anthony_Yio13-Apr-04 0:42 
GeneralRichEditView error when closing VC.Net app Pin
BlackDice8-Apr-04 6:47
BlackDice8-Apr-04 6:47 
GeneralStrings Pin
Billly1237-Apr-04 23:41
sussBillly1237-Apr-04 23:41 
GeneralRe: Strings Pin
Cyric7419-Apr-04 13:55
Cyric7419-Apr-04 13:55 
GeneralCasting Problem for a beginner Pin
Hosam CFJ6-Apr-04 11:21
Hosam CFJ6-Apr-04 11:21 
GeneralRe: Casting Problem for a beginner Pin
Christian Graus6-Apr-04 11:41
protectorChristian Graus6-Apr-04 11:41 
GeneralRe: Casting Problem for a beginner Pin
Hosam CFJ6-Apr-04 12:18
Hosam CFJ6-Apr-04 12:18 
GeneralRe: Casting Problem for a beginner Pin
Christian Graus6-Apr-04 12:20
protectorChristian Graus6-Apr-04 12:20 
GeneralRe: Casting Problem for a beginner Pin
Nemanja Trifunovic6-Apr-04 13:14
Nemanja Trifunovic6-Apr-04 13:14 
GeneralRe: Casting Problem for a beginner Pin
Nemanja Trifunovic6-Apr-04 13:16
Nemanja Trifunovic6-Apr-04 13:16 
GeneralRe: Casting Problem for a beginner Pin
BlackDice12-Apr-04 11:07
BlackDice12-Apr-04 11:07 
GeneralInvitation Pin
Member 7951483-Apr-04 6:23
Member 7951483-Apr-04 6:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.