|
I am doing it on Linux with a gcc compiler 3.2
|
|
|
|
|
Ups, I didn't notice.
43 68 65 65 72 73 2c
4d 69 63 68 61 65 6c
|
|
|
|
|
try using signal()
u can do anythin with it
|
|
|
|
|
Hello folks!
I urgently need to go through a C++ source code for checking whether in an algebraic expression the brackets and braces () and {} are nested. I have been trying to write it for a while now, actually I tried two ways but thats too much loops one in another for my level. Thanks, you would save me!
|
|
|
|
|
Hi,
In my Opinion, stack would be the better choice when task is expression parsing.
Thanks
Jitendra
|
|
|
|
|
Hello programmers,
I having problems with a combo box. I populate the combo box with strings. I am trying to write a fucntion that displays a message box and prompts the user to select a item from the combo box when the current selection is empty.
|
|
|
|
|
If nothing is selected the SelectedIndex property is null so you can use that or you can set some default value of SelectedIndex so that something is always selected by default. At the end you can put an empty string and set SelectedIndex to it's index and test if combo->Text is empty.
--Nikola--
modified 7-Dec-20 21:01pm.
|
|
|
|
|
I write one dll in Managed C++, I add reference to WebProject, all done but when I open webpage design it occur an error "failed to load design..." someone can help me how to repair it.
thanks
Nho'c Ti`
|
|
|
|
|
I would like to use Extended MAPI in my C# programm, read a String-Property from a Message.
For this purpos I write a managed/unmanaged C++ DLL.
I have an Object* from mail.MAPIOBJECT which should be of the type IUnknown according to Microsoft documentation.
I need an LPMAPIPROP for HrGetOneProp(LPMAPIPROP pmp, int ulPropTag, LPVOID lppPro) which can be (I'm not sure, but I found it on a webpage) a pointer to a IUnknown.
But what are the lines between?
I tried:
<br />
static String* GetStringProperty(Object* MAPIObject, int PropertyNumber) {<br />
String* Val; <br />
char* bufVal;<br />
IntPtr pUnk = Marshal::GetIUnknownForObject(MAPIObject);<br />
LPMAPIPROP pMsgMAPI = (LPMAPIPROP)pUnk.ToPointer();<br />
if (pMsgMAPI!=0) {<br />
int hRes = HrGetOneProp(pMsgMAPI, PropertyNumber, (LPBYTE*)&bufVal);<br />
if (bufVal != 0) {<br />
if (hRes == 0) {<br />
Val = Marshal::PtrToStringUni(bufVal);<br />
}<br />
MAPIFreeBuffer(bufVal);<br />
}<br />
}<br />
return Val;<br />
}<br />
pUnk gets a Value but pMsgMAPI/IUnknown says undefined.
Please help
Bernhard Mähr
Spam these adresses: SpamCatcher@CuteConnections.Com Delete@CuteConnections.Com Recycle@BillyX.com Muell@BillyX.com
|
|
|
|
|
Is MAPIObject holding an actual object instance?
|
|
|
|
|
Hi,
Please see following codes on CRC 32:-
CRC32.h
#ifndef _CRC_32_H_EA6C0EE0_BC30_11d5_B625_A58C4DF45B22_INCLUDED
#define _CRC_32_H_EA6C0EE0_BC30_11d5_B625_A58C4DF45B22_INCLUDED
#if MSCVER > 1000
#pragma once
#endif
#ifndef WINDOWS
#include <windows.h>
#endif
#define WM_CRC_THREAD_DONE WM_APP + 0X2DB1
class CRC_32
{
typedef struct tag_CRCstruct
{
CRC_32 *pCRC_32;
TCHAR FileName[MaxPath];
LPBYTE pByte;
UINT size;
HWND hWnd;
HANDLE Thread;
} CRCStruct, *LPCRCSTRUCT;
public:
CRC_32();
DWORD CalcCRC(LPCTSTR FileName, HWND ProgressWnd = NULL);
DWORD CalcCRC(LPVOID buffer, UINT Size, HWND ProgressWnd = NULL);
private:
static DWORD WINAPI CRC32ThreadProc (LPVOID lpVoid);
void Calculate (const LPBYTE buffer, UINT Size, ULONG &crc);
ULONG Reflect (ULONG ref, char ch);
ULONG Table[256];
};
#endif
******************************************************************************
CRC32.cpp
#include "CRC2.h"
#include <io.h>
#include <fcntl.h>
#include <share.h>
#include <tchar.h>
#include <commctrl.h>
#define BUFFERSIZE 102400
DWORD WINAPI CRC_32::CRC32ThreadProc(LPVOID lpVoid)
{
LPCRCStruct pCRCSt = (LPCRCStruct)lpVoid;
ULONG CRC = 0xFFFFFFFF;
HWND Progress = NULL;
if (::IsWindow(pCRCSt->hWnd))
{
Progress = pCRCSt->hWnd;
::PostMessage(Progress, PBM_SETPOS, 0,0);
::PostMessage(Progress, PBM_SETRANGE32, 0, 100);
}
if (pCRCSt->pByte)
{
for (UINT offset = 0; offset < pCRCSt->size; offset += BUFFERSIZE)
{
pCRCSt->pCRC_32->Calculate(pCRCSt->pByte + offset, (pCRCSt->size - offset > BUFFERSIZE) ? BUFFERSIZE : (pCRCSt->size - offset), CRC);
if (::IsWindow(Progress))
{
int percent = offset > pCRCSt->size ? 100 : (int)(((double) offset / (double)pCRCSt->size) * 100);
::PostMessage(Progress, PBM_SETPOS, PERCENT, 0);
}
}
}
else if (pCRCSt->FileName)
{
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)
{
_lseekie64 (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(theFile)
}
}
CRC ^= 0xFFFFFFFF;
if (IsWindow(Progress))
::PostMessage(::GetParent(Progress), WM_CRC_THREAD_DONE, (WPARAM)pCRCSt->Thread, CRC);
delete pCRCSt->pByte;
delete pCRCSt;
return CRC;
}
CRC_32::CRC_32()
{
ULONG ulPolynomial = 0x04C11DB7;
for (int i = 0; i <=0xFF; i++)
{
Table[i] = Reflect(i, 8) <<24;
for (int j = 0; j < 8; j++)
Table[i] = (Table[i] << 1) ^ (Table[i] & (1 << 31) ? ulPolynomial : 0);
Table[i] = Reflect(Table[i], 32);
}
}
ULONG CRC_32::Reflect (ULONG ref, char ch)
{
ULONG value = 0;
//swap bit 0 for bit 7, 1 for 6, 2 for 5 and so on
for (int i = 1; i < (ch + 1); i++)
{
if (ref & 1)
value |= 1 << (ch - 1);
ref >>= 1;
}
return value;
}
DWORD CRC_32::CalcCRC(LPVOID buffer, UINT size, HWND ProgressWnd)
{
if (!buffer || !size)
return 0;
if (!IsWindow(ProgressWnd))
{
DWORD CRC = 0xFFFFFFFF;
Calculate ((LPBYTE)buffer, size, CRC);
return CRC ^ 0xFFFFFFFF;
}
LPCRCStruct pCRCSt = new CRCStruct();
DWORD ThreadID;
HANDLE Handle = ::CreateThread(NULL, 0, CRC32ThreadProc, (LPVOID)pCRCSt, CREATE_SUSPENDED, &ThreadID);
if (Handle)
{
//sucessful created thread
pCRCSt->pCRC_32 = this;
pCRCSt->FileName[0] = 0;
pCRCSt->pByte = new BYTE[size];
memcpy(pCRCSt->pByte, buffer, size);
pCRCSt->size = size;
pCRCSt->hWnd = ProgressWnd;
pCRCSt->Thread = Handle;
::ResumeThread(Handle);
}
else
delete pCRCSt;
return (DWORD) Handle;
}
DWORD CRC_32::CalcCRC(LPCTSTR FileName, HWND ProgressWnd)
{
DWORD attrib = ::GetFileAttributes(FileName);
if (attrib == 0xFFFFFFFF || attrib & FILE_ATTRIBUTE_DIRECTORY)
return 0;
LPCRCStruct pCRCSt = new CRCStruct();
pCRCSt->pCRC_32 = this;
_tcsncpy(pCRCSt->FileName, FileName, MaxPath);
pCRCSt->pByte = NULL;
pCRCSt->size = 0;
pCRCSt->hWND = ProgressWnd;
pCRCSt->Thread = NULL;
if (!IsWindow(ProgressWnd))
{
return CRC32ThreadProc((LPVOID)pCRCSt);
}
DWORD ThreadID;
HANDLE Handle = ::CreateThread(NULL, 0, CRC32ThreadProc, (LPVOID)pCRCSt, CREATE_SUSPENDED, &ThreadID);
if (Handle
{
pCRCSt->Thread = Handle;
::ResumeThread(Handle);
}
else
delete pCRCSt;
return (DWORD) Handle;
}
When I run thr program, a lot errors prompt. Please help me.....
Thank you in advance!
|
|
|
|
|
This code doesn't seem to be Managed C++ - just normal Visual C++ code (so proper forum would be Visual C++ forum). But anyway...
Here is some quick notes:
1) #include "CRC2.h" --> #include "CRC32.h" ?
2) Also some other includes seem to be missing. I guess that they didn't copy to your message.
PBM_SETPOS, PBM_SETRANGE32 --> CommCtrl.h
PERCENT --> Unkonwn include
_O_RDONLY, _O_SEQUENTIAL, _O_BINARY, _SH_DENYWR --> File constants from fcntl.h
_SH_DENYWR --> Sharing constant from share.h
_tsopen --> Routine mapping from TCHAR.H
_sopen --> open file for sharing from io.h
3) LPCRCStruct --> LPCRCSTRUCT (C++ is case sensitive)
4) MaxPath --> Normally MAX_PATH
5) close(theFile) --> close(theFile);
6) _lseekie64 --> _lseeki64
7) ::PostMessage(Progress, PBM_SETPOS, PERCENT, 0); --> ::PostMessage(Progress, PBM_SETPOS, percent, 0);
8) int percent = (int) (((long double)done / (long double)length) * 100); --> You need to calculate length from somewhere.
9) pCRCSt->hWND --> pCRCSt->hWnd
10) if (Handle --> if (Handle)
11) void Calculate (const LPBYTE buffer, UINT Size, ULONG &crc); --> Where is method definition?
My include list in stdafx.h:
#include <io.h>
#include <tchar.h>
#include <windows.h>
#include <CommCtrl.h>
#include <fcntl.h>
#include <share.h>
#include <TCHAR.H>
Some includes might be unnecessary. These changes should compile files - but I don't have any idea is that doing what it is supposed to do.
There is also some ready CRC32 function implementations here in code project. For example:
CRC32: Generating a checksum for a file[^]. If you want to develope managed code, you should check out Cyclic Redundancy Check (CRC32) HashAlgorithm[^]. There is also more implementations and examples - just try search.
|
|
|
|
|
Hi,
Thanks for the reply. I had implement my codes as per your advise. Few more questions: what do you mean by:-
8) int percent = (int) (((long double)done / (long double)length) * 100); --> You need to calculate length from somewhere.
11) void Calculate (const LPBYTE buffer, UINT Size, ULONG &crc); --> Where is method definition?
(any more clear example to explain above two?)
After debugging(implemented code as follwoing), I have an error now which is as I underline in my code (prompt me erroe 2065, 'lenght': undeclared identifier, error executing cl.exe). How can I solve this?
//header file remain the same as previsous sent
#include "CRC32.h"
#include <io.h>
#include <fcntl.h>
#include <share.h>
#include <tchar.h>
#include <tchar.h>
#include <commctrl.h>
#include <windows.h>
#define BUFFERSIZE 102400
DWORD WINAPI CRC_32::CRC32ThreadProc(LPVOID lpVoid)
{
LPCRCSTRUCT pCRCSt = (LPCRCSTRUCT)lpVoid;
ULONG CRC = 0xFFFFFFFF;
HWND Progress = NULL;
if (::IsWindow(pCRCSt->hWnd))
{
Progress = pCRCSt->hWnd;
::PostMessage(Progress, PBM_SETPOS, 0,0);
::PostMessage(Progress, PBM_SETRANGE32, 0, 100);
}
if (pCRCSt->pByte)
{
for (UINT offset = 0; offset < pCRCSt->size; offset += BUFFERSIZE)
{
pCRCSt->pCRC_32->Calculate(pCRCSt->pByte + offset, (pCRCSt->size - offset > BUFFERSIZE) ? BUFFERSIZE : (pCRCSt->size - offset), CRC);
if (::IsWindow(Progress))
{
int percent = offset > pCRCSt->size ? 100 : (int)(((double) offset / (double)pCRCSt->size) * 100);
::PostMessage(Progress, PBM_SETPOS, percent, 0);
}
}
}
else if (pCRCSt->FileName)
{
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)
{
_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(theFile);
}
}
CRC ^= 0xFFFFFFFF;
if (IsWindow(Progress))
::PostMessage(::GetParent(Progress), WM_CRC_THREAD_DONE, (WPARAM)pCRCSt->Thread, CRC);
delete pCRCSt->pByte;
delete pCRCSt;
return CRC;
}
CRC_32::CRC_32()
{
ULONG ulPolynomial = 0x04C11DB7;
for (int i = 0; i <=0xFF; i++)
{
Table[i] = Reflect(i, 8) <<24;
for (int j = 0; j < 8; j++)
Table[i] = (Table[i] << 1) ^ (Table[i] & (1 << 31) ? ulPolynomial : 0);
Table[i] = Reflect(Table[i], 32);
}
}
ULONG CRC_32::Reflect (ULONG ref, char ch)
{
ULONG value = 0;
//swap bit 0 for bit 7, 1 for 6, 2 for 5 and so on
for (int i = 1; i < (ch + 1); i++)
{
if (ref & 1)
value |= 1 << (ch - 1);
ref >>= 1;
}
return value;
}
DWORD CRC_32::CalcCRC(LPVOID buffer, UINT size, HWND ProgressWnd)
{
if (!buffer || !size)
return 0;
if (!IsWindow(ProgressWnd))
{
DWORD CRC = 0xFFFFFFFF;
Calculate ((LPBYTE)buffer, size, CRC);
return CRC ^ 0xFFFFFFFF;
}
LPCRCSTRUCT pCRCSt = new CRCStruct();
DWORD ThreadID;
HANDLE Handle = ::CreateThread(NULL, 0, CRC32ThreadProc, (LPVOID)pCRCSt, CREATE_SUSPENDED, &ThreadID);
if (Handle)
{
//sucessful created thread
pCRCSt->pCRC_32 = this;
pCRCSt->FileName[0] = 0;
pCRCSt->pByte = new BYTE[size];
memcpy(pCRCSt->pByte, buffer, size);
pCRCSt->size = size;
pCRCSt->hWnd = ProgressWnd;
pCRCSt->Thread = Handle;
::ResumeThread(Handle);
}
else
delete pCRCSt;
return (DWORD) Handle;
}
DWORD CRC_32::CalcCRC(LPCTSTR FileName, HWND ProgressWnd)
{
DWORD attrib = ::GetFileAttributes(FileName);
if (attrib == 0xFFFFFFFF || attrib & FILE_ATTRIBUTE_DIRECTORY)
return 0;
LPCRCSTRUCT pCRCSt = new CRCStruct();
pCRCSt->pCRC_32 = this;
_tcsncpy(pCRCSt->FileName, FileName, MAX_PATH);
pCRCSt->pByte = NULL;
pCRCSt->size = 0;
pCRCSt->hWnd = ProgressWnd;
pCRCSt->Thread = NULL;
if (!IsWindow(ProgressWnd))
{
return CRC32ThreadProc((LPVOID)pCRCSt);
}
DWORD ThreadID;
HANDLE Handle = ::CreateThread(NULL, 0, CRC32ThreadProc, (LPVOID)pCRCSt, CREATE_SUSPENDED, &ThreadID);
if (Handle)
{
pCRCSt->Thread = Handle;
::ResumeThread(Handle);
}
else
delete pCRCSt;
return (DWORD) Handle;
}
Again, thanks in advance!
|
|
|
|
|
8) You don't declare and give value for "length". This is why you get error C2065. For example:
<code>
int main()
{
int i = 100 * x;
}
</code>
To solve problem:
<code>
int main()
{
int x = 1;
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)
{
long length = _lseeki64( theFile, 0L, SEEK_END );
if( length == -1L )
{
size = 0L;
switch( errno )
{
case EBADF:
break;
case EINVAL:
break;
default:
break;
}
}
if( length <= 0 )
{
length = 1L;
}
_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))
{
done += size;
int percent = (int) (((long double)done / (long double)length) * 100);
::PostMessage(Progress, PBM_SETPOS, percent, 0);
}
}
}
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++).
|
|
|
|
|
Hegot the code from http://www.codeproject.com/cpp/crc32_large.asp[^]
I do not know why he didn't ask his question in the article forum there, instead of posting partial code here
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
I installed Managed DirectX but I don't have access to the namespaces. When I try using Microsoft:: all I have access to is Win32.
I have the includes folder list with "C:\DX90SDK\Include" at the top and "C:\DX90SDK\Lib" at the top of the library folder list. Those directories contain the files, but for some reason it is not reading them.
Any help would be great.
|
|
|
|
|
I think that you need to add reference to managed DirectX DLL. "References" -> Right click -> Add reference -> .NET -> Browse to .DLL.
|
|
|
|
|
|
I am calling DllImport so I need the namespace "System::Runtime::InteropServices" but I keep getting the error:
error C2872: 'FILETIME' : ambiguous symbol
If I comment out the namespace, this problem goes away, instead it gives me this error:
error C2337: 'DllImport' : attribute not found; it is neither a built-in nor a custom attribute that is accessible in the current namespace
Any help would be great.
|
|
|
|
|
use _FILETIME instead.
Sonork 100.41263:Anthony_Yio
Life is about experiencing ...
|
|
|
|
|
I have an app that I recently ported to .Net (an SDI app with Richedit as the view type). Everything is working fine and it runs fine with native and managed code mixed. But when I close the app, I get this error message: An unhandled exception of type 'System.NullReferenceException' occurred in FB.exe
Additional information: Object reference not set to an instance of an object.
this is happening in the following procedure, which I have never touched. (the offending line is pointed out)
CRichEditCntrItem* CRichEditView::GetInPlaceActiveItem() const
{
ASSERT(m_lpRichEditOle != NULL);
CRichEditDoc* pDoc = GetDocument();
CRichEditCntrItem* pItem = NULL;
CReObject reo;
HRESULT hr = m_lpRichEditOle->GetObject(REO_IOB_SELECTION, &reo,
REO_GETOBJ_ALL_INTERFACES);
if (GetScode(hr) == S_OK && (reo.dwFlags & REO_INPLACEACTIVE))
{
pItem = pDoc->LookupItem(reo.poleobj);
if (pItem == NULL)
pItem = pDoc->CreateClientItem(&reo);
ASSERT(pItem != NULL);
}
return pItem;
} I hope anyone can help me. Thanks
If it's broken, I probably did it
bdiamond
|
|
|
|
|
Need to devise code for the following problem
String Line
Character CharSelect
Integer Begin
Returns the index of the first occurrence of the character CharSelect in string Line starting from index Begin
If Line has value “Most people find this hard” and if CharSelect has value ‘t’ and Begin has value 5 then 18 is returned.
Any help much appreciated.
Bill
|
|
|
|
|
String *Line = S"Most people find this hard";
String *char = S"t";
Int16 iBegin = 5;
//Substring Line to all characters from iBegin on
//Find index of 'char' in the substring
Int16 iIndex = Line->Substring(iBegin)->IndexOf( char );
//Index total by adding whatever iIndex found with iBegin
Console::Write( iIndex + iBegin );
***
That's probably the most simple way. There are some other ways (using IndexOf/IndexOfAny, or some other string functions that I don't recall at the moment) that may also work for finding a character within a specific range.
Cyric
|
|
|
|
|
I have just started moving to Visual C++ 2003, and I have faced the following problem. I want to make an index (std::map<int, int> and std::map<string, int> in VC6.0). I have seen the Hashtable and the SortedList, but I couldn't use them. I got the error that myHashtable->Add(1, 2) can't convert from int to a managed object, and I couldn't solve it.
I hope someone can help me solve this problem. Thank you in advance.
|
|
|
|
|
Why don't you keep using the STL ? Just because you're using managed C++ ( why? ) does not mean you have to use .NET containers, does it ?
It looks like MC++ sucks, and cannot handle that a number is not an object. C# would box it for you automatically.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|