|
There are many articles about these topics here on CP.
Don't try it, just do it!
|
|
|
|
|
how would i select a number between 2 numbers? say between 0 and 40, numbers will vary, and keep selecting a unique number till it got them all but none repeated?
Any helps always apprecieated
shotgun
|
|
|
|
|
An easy way would be creating a dynamic-size array, put all the numbers in there, choose one, remove it from the array and then choose another one and so on....
Example:
Number 40-44
Put 40, 41, 42, 43, 44 in an array. The indexes will be 0, 1, 2, 3, 4.
Now get a random number between 0 and 4, fetch the number with that index from the array and remove it then.
The next round you get a random number between 0 and 3, and so on....
Don't try it, just do it!
|
|
|
|
|
...um thanks for the reply, if I'm going to get a random number between 0 and 4, why not just go for the gusto and get a random between 40 - 44, and save the in between and the array?
shotgun
|
|
|
|
|
You need the array to keep track of what numbers you've used. Most random number generators don't guarantee that you'll get a unique sequence. For example, you could get 0,5,12,3,4,5,...
Software Zen: delete this;
|
|
|
|
|
Hi All
This is a basic question but am I correct in saying that the difference between Build, Rebuild and Clean when building is as follows:
Build - Creates a pre-compiled file from scratch recreating all the intermediate files.
Rebuild - Just updates those intermediate files that require changes since last build.
Clean - Deletes all the intermediate files.
Regards
Jeremy
|
|
|
|
|
JSadleir wrote:
Clean - Deletes all the intermediate files. and also the output files!
Rebuild: Same as Clean, but a new Build is launched after it.
Build: Compile all changed files and link.
Build doesn't say anything about pre-compiled header files.
Don't try it, just do it!
|
|
|
|
|
I've been trying to make Visual Studio show refences to DLL function calls by name in the debugger in Disassembly just like in W32Dasm, but I don't find an option for it anywhere. Can anybody help?
|
|
|
|
|
As far as I know it is not (yet) possible to list references in Visual Studio.
Don't try it, just do it!
|
|
|
|
|
I want to restart the process using the information of the previoulsy suspended process i.e. baseAddr,region,state, allocationbase, e.t.c but now i am stuck. It does not start even though i provided info from the file where it has to read from.
my restart function is below here. What am i missing...
<br />
<br />
case 6:
<br />
lpBaseAddress = 0;<br />
hProcess = mbi.BaseAddress;<br />
SetThreadContext( <br />
hThread, <br />
lpContext <br />
);<br />
<br />
<br />
if (OpenProcess(dwDesiredAccess, bInheritHandle,dwThreadId, GetlastError()) == NULL) <br />
printf("Unable to open thread\n");<br />
<br />
SuspendThread(pi.hThread);
<br />
fp = fopen("info.bin","r");<br />
if( fp )<br />
nSize = 10000;
lpBuffer = 0;
<br />
WriteProcessMemory(<br />
dwDesiredAccess,
lpBaseAddress,
lpBuffer,
nSize,
lpNumberOfBytesWritten
);<br />
<br />
printf("Numbers of bytes writen: ",lpNumberOfBytesWritten);<br />
<br />
ResumeThread(dwDesiredAccess);
GetLastError();<br />
<br />
break;<br />
<br />
oam
|
|
|
|
|
I have a SDI application in which I need to be able to allow the user to interact with controls within a dockable control bar at all times. At times, the app displays modal dialogs. During the modal dialog display, I still need the user to be able to interact with the control bar. Does anyone have any suggestions as to whether or not it is possible to have a modal dialog displayed while having certain pieces of the main app still active?
--
Art Poley
New River Kinematics
309 McLaws Circle
Suite B
Williamsburg, VA 23185
www.kinematics.com
|
|
|
|
|
It isn't, by definition.
From Here[^]
When creating the modal dialog box, the system makes it the active window. The dialog box remains active until the dialog box procedure calls the EndDialog function or the system activates a window in another application. Neither the user nor the application can make the owner window active until the modal dialog box is destroyed.
What you need is a "modeless" dialog.
Steve T
|
|
|
|
|
Unfortunately, I don't have the luxury of making every dialog modeless. I have, however, figured out a way to defeat the disabling of the parent (EnableWindow) that the modal dialog does. I've overridden the ON_WM_CANCELMODE and ON_WM_ACTIVATE callbacks within the mainframe. Doing so, I know when a modal dialog is invoked, since the OnCancelMode is invoked. Then when the OnActivate is invoked, letting me know the frame has become inactive, I can EnableWindow(TRUE) the mainframe and then the modal dialog behaves like a modeless. But, I don't want the entire app to be accessible by the user... just the items within the controlbar. Thus, I'm looking to see if anyone has figured out a nice way to work around the issue.
|
|
|
|
|
Hi all,
I'm developing an extension to Explorer on windows 2000 and I want to insert an icon in my option of the context menu. Everything is already working but the icon. Only to clarify, I want to do exactly the same WinZip does on the context menu (insert an option with an icon). Does anybody has an example of how I do this?
Thanks,
Luiz.
|
|
|
|
|
|
I created a template class like
template <class T><br />
class CProtectedBuffer <br />
{<br />
public: <br />
int DeQueue(T &cElement);<br />
int Enqueue(const T &newElem);<br />
CProtectedBuffer();<br />
virtual ~CProtectedBuffer();<br />
private :<br />
void Enter();<br />
void Leave();<br />
CRITICAL_SECTION cs ; <br />
T t[MAX_PBUF_SIZE] ; <br />
int objCount;<br />
<br />
int headIndex ;<br />
int tailIndex;<br />
int size ; <br />
<br />
};
Now I want to reuse this template to store objects of a custom class which is :
<br />
<br />
class RcvBuffer{<br />
<br />
public : <br />
RcvBuffer():toolName(""),buffer(0),packetSize(0)<br />
{<br />
}; <br />
~RcvBuffer(){<br />
if(buffer){<br />
delete buffer ;<br />
buffer = 0 ; <br />
}<br />
};<br />
<br />
const RcvBuffer& operator=(const RcvBuffer &rhs)<br />
{<br />
if(buffer){<br />
delete [] buffer ; <br />
buffer = 0;<br />
}<br />
int sz = rhs.GetPacketSize() ; <br />
if(sz){<br />
toolName = rhs.GetToolName();<br />
packetSize = sz ; <br />
buffer = new UINT8[sz] ;<br />
for(int i=0;i<sz;i++){<br />
buffer[i] = rhs.BufferValueAt(i);<br />
}<br />
} <br />
return (*this); <br />
<br />
};<br />
<br />
const int GetPacketSize() const <br />
{<br />
return packetSize ; <br />
};<br />
<br />
const UINT8 BufferValueAt(const int &index) const <br />
{<br />
if(index<packetSize ){<br />
return buffer[index];<br />
}<br />
return 0;<br />
};<br />
const string& GetToolName() const <br />
{<br />
return toolName;<br />
};<br />
<br />
int Clear() <br />
{<br />
if(buffer){<br />
delete buffer ;<br />
buffer = 0 ; <br />
}<br />
packetSize = 0; <br />
toolName ="";<br />
<br />
};<br />
private : <br />
string toolName ;<br />
UINT8 *buffer ;<br />
int packetSize ; <br />
};
Here is the part implementation of the template class
template <class T><br />
CProtectedBuffer<T>::CProtectedBuffer():headIndex(0),tailIndex(0),size(0)<br />
{<br />
::InitializeCriticalSection(&cs);<br />
<br />
<br />
<br />
}<br />
template <class T><br />
CProtectedBuffer<T>::~CProtectedBuffer()<br />
{<br />
..<br />
..<br />
..<br />
}
I am using the code like
CProtectedBuffer<RcvBuffer > bBuff ;
I am getting the following linker errors :
linking...<br />
<small>EepromServer.obj : error LNK2001: unresolved external symbol "public: __thiscall CProtectedBuffer<class RcvBuffer>::CProtectedBuffer<class RcvBuffer>(void)" (??0?$CProtectedBuffer@VRcvBuffer@@@@QAE@XZ)<br />
EepromServer.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall CProtectedBuffer<class RcvBuffer>::~CProtectedBuffer<class RcvBuffer>(void)" (??1?$CProtectedBuffer@VRcvBuffer@@@@UAE@XZ)<br />
Debug/EepromServer.exe : fatal error LNK1120: 2 unresolved externals<br />
Error executing link.exe.</small>
If someone can advise
|
|
|
|
|
Do you have the implementation part of CProtectedBuffer in a .cpp of its own? If so, it's no wonder that the linker misses those definitions: templates must de declared and defined in a header file to be included by the user code. Try moving all the CProtectedBuffer implementation stuff to protectedbuffer.h (or whatever the header is named), drop protectedbuffer.cpp and please check if things improve.
To be strict, it is not exactly true that templates must be defined in their header file, but this rule will work 100% of the time. If you're really curious about how templates definitions are located and instantiated, google for "template compilation model" (warning, the issue is rather technical.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Joaquín M López Muñoz wrote:
Do you have the implementation part of CProtectedBuffer in a .cpp of its own? If so, it's no wonder that the linker misses those definitions: templates must de declared and defined in a header file to be included by the user code. Try moving all the CProtectedBuffer implementation stuff to protectedbuffer.h (or whatever the header is named), drop protectedbuffer.cpp and please check if things improve.
yes the code links properly , but still I cannot fathom why the linker cannot get the implementation ? I recollect having once developed a generic Linked List class and am pretty sure I had a separate implementation File .
Anyways this works and really appreciate your help
|
|
|
|
|
Hi all,
I want to detect the computers in a star network using winsok2 or winsock,
and also I want to send a message to these computers without having any client program.
Please help me,
Thanks.
|
|
|
|
|
dSolariuM wrote:
I want to detect the computers in a star network using winsok2 or winsock...
How about NetServerEnum() ?
dSolariuM wrote:
...I want to send a message to these computers without having any client program.
And NetMessageBufferSend() ?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi
I am developing an application using multi threading concept in Win32 Service which runs on Windows2000 Server.
Here I have used memcpy() function to copy one structure into another.
But it doesn't seems to be copying anything. What seems to be the problem. I have used all the parameter properly. It doesn't gives any message but still it doesn't show anything which needs to be printed.
e.g
=============
struct UsrProfile
{
int a;
int b;
char *str;
char *MainStr;
}
MasterServiceThread(CClass *objPassed)
{
UsrProfile UsrDlts;
Create ChildThread here...
Retrieve details for structure....
UsrDlts.a = 10;
UsrDlts.b = 11;
UsrDlts.str ="Mahesh";
}
ChildThread(CClass *objPassed)
{
UsrProfile Usr;
memcpy(&Usr, &ObjPassed->UsrDlts, sizeof(UsrProfile));
....blah blah....
}
Here it doesn't coping the data that needs to be copied into Usr structure object..
Any idea why it happens....?
Thankx in advance
Mahesh
Amarelia Maehsh
Gujarat
India
|
|
|
|
|
Amarelia wrote:
Here it doesn't coping the data...
How are you verifying this?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I m veryfing by printing data of structure after copying...i.e Usr.a, Usr.b, Usr.str...etc...and it gives nothing....
Is there any other function to copy data from one structure to another structure..?
Thankx for your previous reply.
Mahesh
Amarelia Maehsh
Gujarat
India
|
|
|
|
|
Is it possible that you are battling a race condition by viewing the contents of the structure before it has had a chance to be copied? Try your same structure-copying code in a single-threaded application and note the results. Hopefully that'll let you know if it is a thread-related issue or not.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hello everybody:
I have a problem when compile a program with creates a thread specific hooh
I try to save the value of SetWindowsHookEx into a HHOOK var type
but when i compile the code the compiler gives me an error...
The error says:
error LNK2001: Unresolved external symbol" public: static HHOOK hhookMyHook
i'm making a class with the declaration of the HHOOK variable, it's of public type and i'm calling it from a function into the class
Why is happens????
|
|
|
|