Visual C++ :: Calling Self-contained Posix Thread?

Mar 2, 2015

pThread turns out to be NULL here. Wondering what the correct way is...

Code:
class CPF_Thread {
public:
unsigned int threadID;
Coordinater coordinater;
virtual UINT proc() {

[Code] .....

View 2 Replies


ADVERTISEMENT

Visual C++ :: Error C3867 Function Call Missing Argument List For Calling Thread Function

Mar 19, 2013

I searched the web for error: C3867... and the discussions where murky or obscure.

My code excerpt is:

#pragma once
#include <windows.h>
#include <stdlib.h>
#include <process.h>
void PutUpfrmIO(void *);
namespace WordParsor {

[Code] .....

I get the generic message:

error C3867: 'WordParsor::Form1::PutUpfrmIO': function call missing argument list; use '&WordParsor::Form1::PutUpfrmIO' to create a pointer to memberc:userskingc++wordparsorwordparsorForm1.h... and the suggestion fix generate another error.

One person suggested the gcroot<> object wrapper... but I do not know how to modify/declair the function or its argument type.

View 2 Replies View Related

C :: Initialize 1D Or 2D Array In Shared Memory (POSIX)

Dec 8, 2014

I am trying to initialize a 2D char array of strings into POSIX shared memory to be shared between 3 other processes. There are plenty of tutorials on how to use a pointer to share a single string or an integer between processes, but I could find no examples on how to initialize 1D or 2D arrays using mmap(). I have posted what I have so far below. It is the first program, which creates the shared memory object and initialize the array char files[20][2][100] with the value files[0][0][0] = ''. What is the proper method to initialize and share an array in C?

(program initializes shared memory object and array)

Code:
#include<fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/shm.h>
#include <sys/stat.h>
#include <sys/mman.h>

int main (int argc, char *argv[]){

[Code] ......

View 5 Replies View Related

C# :: Getting Text Contained In External Application

May 8, 2012

i'm iterating through the system processes an when i find a process that belongs to a text oriented application, i want to read that text inside the external app. For example, when i get the process to an instance of notepad, i want to get the text contained inside notepad. i've tried to do it using Process.MainWindowHandle pointer, but with no success. How to do it? (This is for an "nanny" app i'm writing, which need access to text in external applications so that i can detect any unappropriated words)

View 3 Replies View Related

C# :: One Thread Trying To Pass Data To Another Thread Using Serial Port

Jul 30, 2014

I have a class which I wrote and one of its object is "SerialPort" .NET class. In my MainWindow I created instance of my class called "SerialPortComm", then I send through some functions of mine, commands to the Serial Port, and I receive answers through "DataReceived" event.

But when I trying to use Dispatcher.BeginInvoke to write my data I have received (successfully), nothing shows on the RichTextBox which I'm trying to write to.

What can caused that, and How I can make it works?

SerialPortComm.cs

public partial class SerialPortComm : UserControl {
public SerialPort mySerialPort = new SerialPort();
public void Open_Port(string comNumber, int baudRate) {
mySerialPort.PortName = comNumber;
mySerialPort.BaudRate = baudRate;

[Code] ....

View 7 Replies View Related

C :: Fastest Way To Check If Bytes Contained In Array Are All X00

Nov 30, 2014

I'll process the raw content of a stream which obviously will be loaded one chunk at a time into an buffer.I need to check if every chunk content is x00 filled. If it is, I'll increase the blank chunks counter of 1.On your personal opinion, which is the fastest an less cycles consuming manner to achieve such result?

I was wondering this: is it possible to make an instant XOR of all the buffer content to check if it does return 0 ?the only way is it to cycle through all the bytes and compare each one of them with 0?

View 1 Replies View Related

Visual C++ :: Add To Listbox Thread

Feb 15, 2015

Startthread get called to launch to update list box.

a)is it the only way to pass string to the PostMessage?. my concern is that allocate using new in each iteration each time slows it down a bit.

b)does OnAddToListBox look memory leak free?.

c)What is the best way handle m_pThread at the end?. Any way to improve it?.

Code:
UINT CMyDlg::Dump(LPVOID lparam) {
HWND *pHndl = static_cast<HWND *>(lparam);
char buffer[200];
for (int i = 0; i < 100; i++) {
sprintf_s(buf,"user %d, data %s",i, "Connected");

[Code] ....

View 8 Replies View Related

Visual C++ :: How To Check Thread With MFC

Feb 12, 2013

I use MFC Find console window and send key to console like this.

Code:
HWND w;
w = FindWindow(NULL, L"c:userspkrudocumentsvisual studio 2010ProjectsCleanVirusDebugCleanVirus.exe");

[Code]....

After program process success in console it not close console windows but it show like this in Output

The thread 'Win32 Thread' (0x1300) has exited with code 0 (0x0).

I think if I can check when VC will show this line, then I can use FreeConsole(); for close console windows.

View 3 Replies View Related

Visual C++ :: Exit Application Using Thread In MFC SDI

Feb 4, 2014

I have a SDI application. I created a method OnClose to handle ON_WM_CLOSE of CMainFrm. This onclose() function calls a method in cmyview.cpp. Here, I created a thread that calls global function and from this function it calls another function in cmyview.cpp. At certain condition my application should close at here, I used postmessgae(WM_CLOSE (or) WM_DESTROY). I am having an error as object reference not set on postmessage(WM_CLOSE) it is going to afxwin2.inl page where exception occurs.

Below is code snippetHere, either j or k will only be true depneds on user input)

MainFrm.cpp:
void CMainFrame::OnClose()
{
CMyView* pview = (CMyView*)((CFrameWnd*)AfxGetMainWnd())->GetActiveView();
pview->method1();
}

[Code]...

View 3 Replies View Related

Visual C++ :: Using One Thread At A Time With CSemaphore

Oct 6, 2014

I need using CSemaphore class in MFC C++ application. I have an edit1 box with multil ine and each line has a string. I'm trying to loop through edit1 box and for each string to start a thread that is using the string for specific function. I'm trying to limit the run of only one thread at the same time with semaphores but all treads start at the same time.

So when i click button1 i loop through edit1 box and start threads:

Code:
void CMFCApplication1Dlg::onButton1Click() {
int i, nLineCount = edit1.GetLineCount();
CString strText, strLine, mesaj;
for (i = 0; i < nLineCount; i++) {

[Code] ....

While looping through edit1 box multi line and starting the threads:

Code:
UINT CMFCApplication1Dlg::StartThread(LPVOID param) {
WaitForSingleObject(semafor, INFINITE); // wait for semafor to signal
THREADSTRUCT* ts = (THREADSTRUCT*)param;
// here i'm doing some operations with the string from edit1 box
ReleaseSemaphore(semafor, 1, NULL); //release the semaphore for next thread to begin
}

Instead of running only one thread at a time all threads start. What am i doing wrong ?

View 14 Replies View Related

Visual C++ :: How To Fork Or Create Thread

Dec 23, 2012

How can I implement the paradigm demonstrated by the code below to run on WinXP?

I want to fork a process or create a thread that shares global variables with the parent process/thread.

The child process/thread monitors the progress of the parent process/thread.

I cannot find documentation for a fork function per se, a Unix term. It might be called something different for WinXP.

I would be happy to use threads instead. But I'm rusty even with Unix application threads; and I know nothing of WinXP application threads.

So any turnkey implementation that demonstrates the simplest use of process or thread functions for my purpose demonstrated below.

In either case, do "forked" processes and threads share global address space in WinXP, as they do in Unix?

I would prefer to avoid the overhead of IPC mechanisms. The "overhead" includes my own relearning curve.

The GUI screwed up my indentation. I would try to correct it. But the proper indentation appears when I edit the posting. I suppose I need to insert real tabs. Haven't figured out how (yet).

Not even real tabs work; and I cannot get the "paste as text" button to behave as I expect. What is the trick for posting indented text in this GUI?

#include "stdafx.h"
#include <stdlib.h>
#include <Windows.h>
long curCount;
int isRunning;
int _tmain(int argc, char* argv[]) {
curCount = 0;
isRunning = 1;

[code]....

View 4 Replies View Related

Visual C++ :: Unable To Display Dialog In UI Thread

Mar 11, 2015

I am having a strange problem trying to display a dialog from a UI thread. The dialog simply fails to display. I have a function DisplayFlashBox(), which creates the UI thread:

CUIThread* CIMUIHelper:: DisplayFlashBox(const CString &sMessage, const int nInstrumentUID) {
CUIThread *pThread = new CUIThread();
pThread->SetString(sMessage);
pThread->SetInstrumentUID(nInstrumentUID);
pThread->CreateThread();

[Code] .....

The dialog doesn't display. When I tried debugging, I found the OnInitDialog() method of CIMFlashBox class doesn't actually return. Very strange. I tried calling the DoModal() method instead of Create, but doesn't display the dialog either.

View 5 Replies View Related

Visual C++ :: Unable To Invoke JScript Functions From Another Thread

May 6, 2013

I have main thread that creates an WebBrowser2 COM object. and i want to invoke JScript functions on it from another thread. i try to use GIT but still doesn't work for me.. there is a problem with marshal WebBrowser2 for JScript?

View 4 Replies View Related

Visual C++ :: Local Variable Be Passed As Parameter Into A New Thread?

Apr 1, 2013

Can local variable be passed as the parameter for a new created thread procedure? Here is the example code:

Code:
void CDLG::some_function()
{
CString strFileName="abc.doc";
//local variable, can it be valid for being passed into the following new thread???
//Can strFileName still be accessed from within the stack of thread procedure?
::AfxBeginThread(ProcessContentThread,(LPVOID)&strFileName);
}

[Code]...

There is another method using variable on the heap,

Code:

void CDLG::some_function()
{
CString strFileName="abc.doc";
CString* pstrFN=new CString(strFileName);
::AfxBeginThread(ProcessContentThread,(LPVOID)pstrFN);
}

[Code]...

I test these code, both methods work as expected, but I doubt whether the first method is a good way. OR if only the second method is the correct way to pass a parameter to a thread.

View 12 Replies View Related

Visual C++ :: Terminate A Thread When User Push Stop Button

Nov 16, 2012

I have a thread with a while(1) loop in it. When the user push the stop button I would like that thread to end.

I thought about creating a bool and checking its value periodically in the thread and when I push the stop button I change the value of the bool for that the thread breaks out of the loop and finishes.

View 5 Replies View Related

Visual C++ :: Obtaining Actual Effective Execution Time Per Thread With Hyperthreading

Jun 13, 2013

I'm looking for a function like GetThreadTimes, but one that gives correct results in a hyperthreading CPU.

For instance, if you start 2 threads on a CPU with 1 physical core and 2 logical cores, GetThreadTimes will say that both these threads use 100% CPU.

However, in reality they only use 50% each. Is there a function that returns correct results, or is there another workaround?

View 8 Replies View Related

Visual C++ :: How To Reduce High CPU Usage Caused By Receiver Thread Of CAN Messages

Feb 13, 2013

I am writing a program which handles the CAN messages Received from BUS.My code is taking almost 60% of CPU usage.

View 14 Replies View Related

Visual C++ :: How To Raise Priority Of MIDI Input Callbacks - Thread Pools

Sep 23, 2014

I'm the author of a realtime MIDI software called ChordEase which makes use of the MIDI aspects of the multimedia API, specifically MIDI input callbacks. In XP and before, these callbacks originated in the kernel and therefore had realtime priority by definition, but from Vista on, they originate in thread pool threads, and have a priority of zero. This is a problem because at priority zero they can be blocked by the GUI thread, causing serious latency, and I have proved that such blocking occurs.

I have experimented with raising the callback thread priority, using either of the following methods: 1) calling SetThreadPriority within the MIDI input callback function, and then setting a flag so that it isn't done repeatedly, or 2) creating a DLL that catches thread creation via DLL_ATTACH_THREAD in DllMain, and calling SetThreadPriority there. The first method is slightly wasteful since the flag has to be tested for every MIDI input event, but it also has the advantage of only affecting the MIDI input threads, whereas the second method affects all threads in the pool regardless of what they're used for. Neither method appears to cause any harmful effects but they make me nervous*. Other possible methods would include 3) using the thread pool API to raise the priority of the pool (assuming I could gain access to the pool handle somehow), or 4) permanently lowering the priority of the GUI thread, which I'm very reluctant to do because of the risk of unintended consequences.

I'm assuming the MIDI input callbacks are using threads in the default thread pool though I haven't actually proved this. Assuming that's so, are these threads private to my application, or is my application sharing them with other applications? Is there a safer way to achieve the result of increasing the priority of MIDI input callbacks? It's incredibly frustrating that MS would change the behavior of MIDI input callbacks so drastically without even telling anyone, but that's how it goes!

[URL] ....

*See for example theses warnings about changing thread pool priorities : [URL] ....

View 13 Replies View Related

Visual C++ :: Mq4 Platform Calling Functions From DLL

Feb 10, 2013

I have Mq4 platform calling functions from DLL some how it doesnt make any differents when I make the call....

// DLL Code

#define WIN32_LEAN_AND_MEAN
#define MT4_EXPFUNC __declspec(dllexport)
using namespace std;
std::string My_String;
#define stringify(mymonths ) # mymonths

[Code] ....

I call this function

bool counts = StartRulls(bars);
Print("counts =",counts );
2013.02.09 23:03:242010.03.31 16:37 My_Mq4.mq4 EURCAD,M5: counts = 1

My result always stays 1

View 4 Replies View Related

Visual C++ :: Calling A Function In AfxBeginThread?

Oct 1, 2014

I have the code:

void go(CMFCApplication1Dlg * pdlg)
{
pdlg->listcontrol1.InsertItem(0, "Row1");
}

then i call it in thread

Code:
void CMFCApplication1Dlg::OnBnClickedButton3()
{
AfxBeginThread(go(this), NULL, THREAD_PRIORITY_NORMAL, 0, 0, NULL);
}

It doesn't work.

View 13 Replies View Related

Visual C++ :: Calling Routines From Fortran 77 Using Win32 DLL

Aug 14, 2014

Is it possible to call VC++ routines using a Win32 DLL form fortran 77??

View 3 Replies View Related

Visual C++ :: Calling Function From OnDraw - Runtime Assertion

Feb 2, 2014

Following function is causing run-time assertion. I am using VC6.0 professional version. My OS is Win7.0. I am calling the function from OnDraw. OnDraw does not contain any other code other than the function call code:

Code:
void CMoireUseCirclesView::UseCircle(CDC* pDC){
int x1, y1, x2, y2;
x1=20;
y1=100;
x2=200;
y2=280;
int color1=0;
int color2=0;

[Code] ....

The assertion is occurring at:

Code:
newPen.CreatePen(PS_SOLID,5, RGB(color1,color2,color3+i));

The error message is:

Debug Assertion Failed
Prog:....
File:wingdi.cpp
Line:1120

Debug is giving following values

Loaded 'ntdll.dll', no matching symbolic information found.
Loaded 'C:WindowsSysWOW64kernel32.dll', no matching symbolic information found.
Loaded 'C:WindowsSysWOW64KernelBase.dll', no matching symbolic information found.
Loaded symbols for 'C:WindowsSysWOW64MFC42D.DLL'

[Code] ...

View 7 Replies View Related

Visual C++ :: Being Argument Array Not Copied When Calling Function

Feb 7, 2013

The code below outputs this:
a[]= 00
a[]= 10
a[]= 10
a[]= 10
a[]= 11
a[]= 11
0.

But I was expecting this:
a[]= 00
a[]= 10
a[]= 10
a[]= 00
a[]= 01
0.

This describes how the process is running in machine:
1. Defining a[2]{0,0}; ii=0; aj=0
2. Calling function func(a,ii,aj) |func({0,0},0,0)|
3. func({0,0},0,0) defining w=0; static aa=0
4. func({0,0},0,0) if(0) returns aa=1
5. func({0,0},0,0) for j=0
6. func({0,0},0,0) for Outputing "00", because a[2]={0,0}, look (1).
7. func({0,0},0,0) for if(!0) | because a[0]=0| returns w+=func(a,ii+1,j) |func({0,0},0+1,0)| and calls func({0,0},1,0)
8. func({0,0},0,0) for if func({0,0},1,0) defining w=0
9. func({0,0},0,0) for if func({1,0},1,0) if(1) returns a[0]=1, because of static aa=1, см 4.
10. func({0,0},0,0) for if func({1,0},1,0) for j=0
11. func({0,0},0,0) for if func({1,0},1,0) for Outputing "10", because of a[2]={1,0}, look row #9
12. func({0,0},0,0) for if func({1,0},1,0) for if(!1) |because a[0]=1|
13. func({0,0},0,0) for if func({1,0},1,0) for j=1
14. func({0,0},0,0) for if func({1,0},1,0) for Outputing "10"
15. func({0,0},0,0) for if func({1,0},1,0) for if(!0) |because a[1]=0|
16. func({0,0},0,0) for if func({1,0},1,0) for if if(1==1) |because ii=1, func({0,0},ii,0)|
17. func({0,0},0,0) for if func({1,0},1,0) for if if return 0
18. func({0,0},0,0) for if w=0 |because func({1,0},1,0) gives 0|
19. func({0,0},0,0) for j=1

And from now, something is happening that I cannot understand:
20. func({0,0},0,0) for Outputing "10"

Why so? If func has itselfs local variables, including a[2]={0,0}.

I was expecting this:
20. func({0,0},0,0) for Outputing "00"

So a[2] array is not local variable. Why it happens?

Code:
#include <iostream>
using namespace std;
int func(bool a[],int ii,int aj) {
int w=0;
static bool aa=0;

[Code] ....

View 3 Replies View Related

Visual C++ :: Calling ATL COM DLL Method (that Opens A Dialog) From Browser?

Oct 11, 2013

I have a COM Object created using ATL (without MFC Support)

The Object has 1 method that opens a Dialog (that does all the rest) and when finish - returns 2 values back (1 is enough)

Currently I call it from another EXE:

hr = CoCreateInstance(
CLSID_MyControl,
NULL,
CLSCTX_INPROC_SERVER,
IID_IMyControl,
(void**) &pMyControl
);

and then:

hr = pMyControl->MyMethod (ATL::CComBSTR(InputString1), ATL::CComBSTR(InputString2), &IntReturned, &IntReturned);

Is it possible to call it as is from a browser ?

How can I Instantiate the object and invoke my method (with params) from the browser ?

will it open the dialog ?

View 3 Replies View Related

Visual C++ :: Calling Default In OnNcPaint Before Painting Override Caption?

Jun 20, 2013

I'm overriding OnNcPaint to do my own caption painting (in a dialog box). If I call "Default" before I do my painting, the default caption and borders remain (as if I'm not painting at all). If I comment out my call to "Default", my caption looks great, but I get no menu bar (I have a menu on the dialog). If I call "DrawMenu" before or after painting, the dialog is all screwed up (and there is no painting in the nonclient area).

I'm running VS2012, on Windows 7.

View 10 Replies View Related

Visual C++ :: Window Created By Calling Create - DestroyWindow Function?

Jan 17, 2013

If a window is created by calling Create, the function DestroyWindow must be called to destroyed it at the end?

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved