|
Take a look in the AmCap Sample in the DXSDK
DirectX 9.0 SDK
It is a good example, but you need have some notion on DirectShow.
[]'s
Marcos Vinícius
|
|
|
|
|
Hi All,
Ive created a bare Win32 DLL. Ive exported a function and can get the functions address with no problems in my calling application.
My problem is after the DLL function is called I get the message "The value of ESP was not properly saved across a function call".
My code is...
DLL HEADER
---------------
#ifdef JDEDXMLPARSER_EXPORTS
#define JDEDXMLPARSER_API __declspec(dllexport)
#else
#define JDEDXMLPARSER_API __declspec(dllimport)
#endif
// This class is exported from the jdedXMLParser.dll
class JDEDXMLPARSER_API CJdedXMLParser {
public:
CJdedXMLParser(void);
dllAddFile(TCHAR* szFile);
// TODO: add your methods here.
};
// This integer is exported
extern JDEDXMLPARSER_API int nJdedXMLParser;
// This function is exported
JDEDXMLPARSER_API AddFile(TCHAR * sz);
DLL CPP
----------
JDEDXMLPARSER_API AddFile(TCHAR *sz)
{
MessageBox(NULL, sz, L"", 0);
//parser.dllAddFile(szFile);
}
CALLING THE DLL
----------------------
// Globals
typedef (WINAPI* AddFile)(TCHAR *sz);
AddFile _AddFile;
void CUnicodeTestDlg::OnBegin()
{
HMODULE m_lib;
TCHAR * szTable = _T("F0101");
m_lib = LoadLibrary(_T("jdedXMLParser.dll"));
_AddFile = (AddFile) GetProcAddress(m_lib, "?AddFile@@YAHPAG@Z");
_AddFile(szTable);
}
When I call _AddFile I get MY message box from the DLL function followed by the system error ESP message. Does anyone know what I am doing wrong here?
I dont have a .def file as im not sure how to link it in and use it so I am using the FULL function name.
Thanks in advance for any help.
Kind Regards,
Chris
|
|
|
|
|
Hi Chris,
I just had the same problem with the ESP error. In my case it was because the exported DLL function had the __stdcall calling convention as part of the function prototype. I wasn't including that in my typedef for the function pointer.
I noticed you export the function with no calling convention, but then include the WINAPI convention in your typedef. Have you tried removing WINAPI from your typedef? See if that works.
Regards,
Justin
|
|
|
|
|
You're right. This happens in VC++ due to a mismatch in the calling function convention. Make sure you are using the correct convention: __stdcall / __cdecl etc.
Bikram
|
|
|
|
|
Does anybody know the class name, part id's and state id's for static controls? MSDN lists details for just about every other control but not statics.
Systems AXIS Ltd - Software for Business ...
|
|
|
|
|
I've been trying to read about the best network I/O model and talked to people about which network I/O model is the best. Different answers from different peopels about the same model.
Asynchronous I/O: One says it's the best model for concurrent operations, an other says it's bad because of a lot of synchronizing/locking when access shared data (such as client list on a server), then a third says, locking is not bad...man, this is kinda confusing.
Synchronous I/O - using select(): I would say this one is bad, because then you have to wait for each operation to copmplete before you can move on. Other people says this is a great network I/O model.
What is your opinion about the best network I/O model?
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
|
|
|
|
|
Asynchronous is very difficult to program. You really have to split up your operations into various states to process as different bits of I/O complete. Typically you'd use asynchronous I/Os to get the best out of a thread-pooled server - you can have more I/O pending than you have threads, and you can perform part of a second client's request while waiting for I/O for the first to complete.
For best performance, you want to have a limited-size pool of threads, rather than one thread per client, for several reasons. Firstly there's overhead in creating and cleaning up threads. Secondly, each thread requires its own stack and possibly its own thread-local resources, which use up memory that you could be using for other things. Thirdly, the more threads there are which can run at any given time, the more time the OS spends switching between threads and the less actually doing work. The ideal is to have only one runnable thread per CPU. SQL Server uses this model (see Inside the User Mode Scheduler[^]).
Writing your code this way can give you the maximum potential performance, but it's hard.
Synchronous I/O is much easier: you simply write the code to perform the required steps in the required order. But you typically need more threads to achieve the same goal; if a thread is blocked waiting for I/O to serve one client, it can't serve another.
Synchronisation is an issue whether you're using asynchronous or synchronous I/O, so long as you're using multiple threads that may access the same shared data. It's a fact of life in a multithreaded program. It doesn't affect your choice of sync or async I/O. Locking reduces your concurrency, sure, if two threads contend on the same shared data. You can potentially improve this by increasing the granularity of your locks - locking less data, and holding locks for less time.
Windows provides the I/O completion port facility for simplifying and improving thread pooling. Threads and I/O handles can be associated with a particular completion port. Handles are associated by calling CreateIoCompletionPort ; threads call GetQueuedCompletionStatus to block waiting for an I/O (on any of the handles associated with the port) to complete. So far, so simple. The twist is that the completion port enforces the maximum concurrency level - it will only unblock threads up to a specified number of threads running concurrently. What's more, if a thread belonging to the port is blocked for any reason, the completion port will release another if a completed I/O is waiting to be processed. This does mean that the number of runnable threads will typically be higher than the ideal one-per-processor.
Finally, to improve processor cache locality, the port releases threads in Last-In-First-Out order - the thread that handles a completed I/O is the last one which called GetQueuedCompletionStatus . These facilities have been present since NT 3.5. They're quite complex, however, for general thread pooling. For that, Windows 2000 also offers the QueueUserWorkItem API.
I suggest reading Programming Server-Side Applications for Windows[^] by Jeffrey Richter.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
When I click on a button I want to appear 3 buttons instead a dialog.How can I do this?Thanks.
|
|
|
|
|
One way is you create 3 that buttons in resource editor. In OnInitDialog, you set three button to be invisible.
When click on a button, you set 3 button to visible mode.
Just call: ShowWindow
Another way is to create buttons when click by CWnd::Create function
|
|
|
|
|
Idon't want a dialog, only 3 buutons.No dialog.
|
|
|
|
|
I don't understand your question. Where three buttons is? Where is the button that you clicked on? Could you give more detaily the problem?
|
|
|
|
|
How can I terminate an application when all I know is its name.
i.e. a running a batch file which starts one task (TaskA.exe) and my task.
I just want on option in my program to abort; i.e. terminate myself and TaskA.exe.
Are they any options to terminate by name, or get the process handle of TackA?
|
|
|
|
|
hi,
no there is no way other than terminate the app by using the process handle. but if we know the process name, then we can enum thru the process list to find the matching process to terminate. some two month back i have replyed the same query. i just copied that reply below:
call TerminateProcess to terminate a process. This needs the process handle as input. Call OpenProcess to get the process handle. This needs processId as input. Call Process32First and Process32Next to loop thru the running process and to get the ProcessId . Call CreateToolhelp32Snapshot before calling Process32First .
sample code is available on msdn.
rgds..mil10
|
|
|
|
|
Thanks for the information and link.
I included the following code into an ABort button, but did not manage to terminate the other application, any ideas?
HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
PROCESSENTRY32* processInfo=new PROCESSENTRY32;
processInfo->dwSize=sizeof(PROCESSENTRY32);
int index = 0;
int processID = 0;
bool handleFound = false;
HANDLE CSLProcess = NULL;
// Here we are passing snapshot handle and PROCESSENTRY32 structure to Process32Next()
// function. After execution, PROCESSENTRY32 structure will contain information about a process.
// We are iterating through a loop until we got FALSE and this means there is now no process left to visit in snapshot and our pointer is at the end of snapshot.
Process32First(hSnapShot,processInfo);
if(strcmp(processInfo->szExeFile,"Csl.exe") == 0)
{
handleFound = true;
processID = processInfo->th32ParentProcessID;
}
while((Process32Next(hSnapShot,processInfo)!=FALSE) && (handleFound == false))
{
if(strcmp(processInfo->szExeFile,"Csl.exe") == 0)
{
handleFound = true;
processID = processInfo->th32ProcessID;
break;
}
}
CSLProcess = OpenProcess(PROCESS_TERMINATE,TRUE,processID);
if(!CSLProcess)
if(TerminateProcess(CSLProcess, 0) == 0)
{
m_strGeneral = "Failed to Terminate CSL.EXE No Assecc Rights";
m_strOutput+= m_strGeneral + crlf; // Total display string; adding m_strNewText at the end
m_Output.SetWindowText(m_strOutput); // Display the new text appended onto the old text
}
else
{
m_strGeneral = "Failed to Terminate CSL.EXE";
m_strOutput+= m_strGeneral + crlf; // Total display string; adding m_strNewText at the end
m_Output.SetWindowText(m_strOutput); // Display the new text appended onto the old text
}
//Don’t forget to close handle.
CloseHandle(hSnapShot);
delete processInfo;
|
|
|
|
|
What is this test
if(!CSLProcess)
?
if OpenProcess succeed CSLProcess != NULL and in your case nothing is done
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Thanks,
Wood and tress etc.
|
|
|
|
|
Hello,
In my application I have a dialogbox which has certain settings. I want to keep those settings until the entire application stops.
Thus I need to keep the variables in memory.
NOTE: The dialog is in a separate dll (I didn't do that ). (so static or structs ,... won't work) My last option is to create a temporary file on starting end deleting it at ending the application.
tnx for your help!
|
|
|
|
|
|
structs will work; you pass a pointer to your struct as a parameter to the dialog create function. The dialog then fills in the data.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Hi
before any one start slandering me about this code i did not
write it(DID NOT).
It is a Question well kinda(HW) and i realy need help i wont take any offence if i whas told i'm stupid, I just need help.
The question is(from Lecturer)
(i) Rewrite the following piece of code correcting all the
problems found(Given the followng code)
void CalculateValues(const int &a, float *b, int &c)<br />
{<br />
d = 20.4;<br />
if(*a = 0)<br />
{<br />
*a += 1;<br />
c = a + d;<br />
}<br />
else<br />
{<br />
b = c / d;<br />
c = a - b + d;<br />
}<br />
}
Included a Hint: if a=4, b=0.0, c=5 When funct return
should be: a=4, b=0.25 and c=24.15.
Need help with the prototype and calculations
PLEASE
Many Thanks.
|
|
|
|
|
bhangie wrote:
*a += 1;
false, a is not a pointer
secondly, it is declared as a const, you cannot write into it.
bhangie wrote:
b = c / d;
b is a float* , you so should write *b in your code when using it. or define it as a float& .
TOXCCT >>> GEII power
|
|
|
|
|
<br />
void CalculateValues(int &a, float &b, int &c)<br />
{<br />
<div style="margin-left=3em;">d = 20.4;<br />
if(0 == a)<br />
{<br />
<div style="margin-left=3em;">a += 1;<br />
c = a + d;</div><br />
}<br />
else<br />
{<br />
<div style="margin-left=3em;">b = c / d;<br />
c = a - b + d;</div><br />
}</div><br />
}<br />
Wout Louwers
|
|
|
|
|
|
bhangie wrote:
d = 20.4;
This variable has not been declared. I assume it is a double (or float ).
bhangie wrote:
if(*a = 0)
Variable a is being passed as a reference to CalculateValues() . Therefore, *a is an incorrect reference since a pointer was not passed to CalculateValues() .
bhangie wrote:
c = a + d;
Different types are being operated on here. You'll probably need to cast the float "down to" an int .
bhangie wrote:
c = a - b + d;
Again, different types are being operated on here. Variable b is a pointer, whereas a and d are not.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
#include<iostream>
#include<iomanip>
using namespace std;
void CalculateValues(const int &a, double *b, double &c)
//c only can be double,if float,then *b=c/d how to transfer from float to double
{c=5;
double d = 20.4;//only double.
if(a == 0)
{
//*a += 1;//error
c = a + d;
}
else
{
*b = c / d;
c =a - *b +d;
cout<<"a="<
|
|
|
|