Visual C++ :: 2 Programs - 1 Dll Sharing Variable?
Mar 16, 2014
my goal:
have 1 program handle the UI
have that program store variables to a DLL
have the 2nd program grab the stored variables to reform some number crunching, without interfering with the UI program, and once done, have it drop the answers back into that DLL, so that the UI can grab it when it's ready.
I have made the 2 programs, + dll
What I've Achieved:
the first program accesses the dll, and loads up a variable (and stays connected to the dll, so that the Dll instance doesn't reset)
I've gotten the DLL to output the variable to make sure it's received it, and stored it to it's own global variable.
the second program connects to the dll successfully, but when it tries to retrieve the data, it returns 0's (NULL's)
My research:from what I've read, so long the dll is connected to a program, all additional programs will attach to the same instance.
how do I make the global variable in the dll be accessible to both programs? (without resorting to saving it to the HDD Idealy)
I'm trying to set up some basic communication between two programs via the registry.
For this I would like to use the functions
Code: int value=10; CString strSection="Data"; CWinApp* pApp = AfxGetApp(); pApp->WriteProfileInt(strSection,ValueName,value); and
Code: CString strSection="Data"; CWinApp* pApp = AfxGetApp(); int value=pApp->GetProfileInt(strSection,ValueName,0); which read/write to the application's registry.
Is there some way of making two different programs use the same application registry?
I'm building a simple little program for minecraft to reduce the repetitiveness, I'm using getpixel, it's slow, but i only need to grab about 6-12 pixels.
but the problem is, I can get the pixel data if I capture from the entire desktop display, but as soon as I tell it to grab from the active window (wich goes MUCH faster) it doesn't return any colour value's.
I'd rather not have to use getDIBits or program in java or anything since I want to keep it fairly kiss, and if it can't be done, then.. ah well, I'll just grab from the entire desktop, speed isn't to much of an issue, but it'll be a pain to keep the window at the same place.
Code: #include <Windows.h> #include <iostream> using namespace std; // vvv Ignore this, it's just used for retrieving the handle of a window without giving the full window name vvvv struct results {
So, as the title says, I'm trying to eliminate false sharing, or, eliminate sharing writes between threads with TBB. The question is how.
Normally I'd make an array whose size is equal to the number of threads, then locally write to a local variable and update the array only at the end of the thread.
But, of course, I cannot seem to get either thread id or total number of threads TBB uses. I found a reference to tbb::enumerable_thread_specific, which as I understand, is supposed to work for exactly this. But as soon as I added it, it hurt performance by ~60% instead of making it better.
How to do this properly? You don't really need to look so hard on how the algorithm works (I don't know either). I know it's not quite right right now due to race conditions, but I'll fix that later. I used a reference implementation that I copied™, and my task is to parallelize it.
The parts where the problem is right now is in red (of course, it's not all problems; it's only a subset of them).
The problem is I have a function which sets some variables and I want to access the variables, but myfunc() is nested too deeply for me to pass a data structure all the way down and to return all the way up. The functions reside in different files. I'm not allowed to use extern structs (i.e. a global variable).
How to use a class and instantiate it in myfunc(). My solutions are:
- using the singleton class method - static variables and function residing in the class (but I'm suspicious of this way. seems like it's just class variables masquerading as global variables.
I am just wondering if it is possible to send a project to someone via email - In a simple way, almost like you would install software from the internet, maybe a setup file, or something. The compiler I use "Dev C++" creates a .cpp file and an executable. Unfortunately, I cannot send that .exe file. How would you recommend sharing a program?
I've changed up my code to the retail checkout WFA I am trying to make. I have an item list filled with objects of the now globally accessible 'Item' class, but I'm having trouble.
Essentially, I want to send an object of the item class chosen from a dropdown menu to form2, where I will fill in certain blank attributes with data entered in form2's text boxes and comboboxes. The problem, it seems, is I need another itemlist in form2 that will hold the object being passed to form 2, so I can then pass all the information to textboxes on form3 (the receipt/review page). It's been more than a year since I coded with C#, and I've forgotten quite a bit. I was also not able to find any tutorials on building an item list without an associated combobox or droplist, which is what I need.
This is my item class (minus most of its properties so the page doesn't stretch).
class Item { public string prodName; public string fName; public string lName; public string ccNum; public string ccProv; public string shipAddr;
[code] ....
For anyone who didn't see my last question, I'm in a User Interface Design class, not a C# class. I know this probably isn't the best code out there, but for my purposes the program just needs to compile beginning to end and pass the data like it should.
There are 3 students (0=John, 1=Peter, 2=William) sharing their meals. Who does the cooking, does the shopping and pays for the bills. End of the month they sum it all up and settle the bills equally. Who must pay the most is outputted at the top, while the person that collects most is at the bottom. Students that have to pay the same amount are listed in the same order as they are ordered in the input. (receiving same amount, the same). Total of the settlement are rounded to whole cents. Sometimes they loose a cent, sometimes they gain one.
So I started making a plan what the program is supposed to do. Pen and paper:
1. Sum of the total amount from all the meals. JohnPaid+PeterPaid+WilliamPaid=Total Total / 3 = FairShare
calculate difference of all three the students
if JohnPaid == FairShare print John receives 0.00
if JohnPaid > FairShare print John receives difference
if JohnPaid < FairShare print John pays difference
Any way to create a variable using a variable in the name? So E.g. if you wanted to create an int named nr(x), and x was 1, you would get an int variable named nr1? How would you do this?
I've copied and pasted my code. The main program, the calculateTaxes.cpp function code and my makefile. I am using the makefile to link these two codes together but I get an error when I type 'make' in the command line.
I receive the error code: assign2c.cpp.text+0x169): undefined reference to 'calculateTaxes(float, float, float*, float*, float*)' collect: ld returned 1 exit status make: *** [main.exe] error 1
so here is a basic program i wrote i am thinking of writing a currency conversion program that does multiple conversions and i was thinking it is possible to do something like this couldnt i call them after i write them as functions
usdtoeuro() usdtokuna()
how would i go about doing that? or can you point me to anything?
I have a mobile application for android coded in javascript and a windows form coded in c#. I want my mobile app to send some data to the c# program. It is fine if the transmission is not secure. I searched the net. I found a site called pastebin.com. Unfortunately it provides api for posting and reading data. However I want something, where I can store,read as well as EDIT the data.
I am trying to experiment with programs and databases. Right now I am trying to set up a database so that my program, which currently just appends its results onto a text file, will instead store each result into a database, because this will make things much easier to access than trying to read specific results from an ever-larger, disorganized text file.
I am just starting out learning C and I am using MinGW, Widnows 7, and cmd.exe.I am starting from scratch and learning very short and simple programs, like 20 lines long.After I use MinGW (gcc) to compile, the programs start up rather slowly, sometimes up to about 3-5 seconds. One with a big nested loop even took about 15 seconds to load. After they run once, the next time they run, it's instant.
Last time I learned from this book, I don't remember them starting so slowly. I use the command "gcc sample.c -o sample".It just concerns me that these tiny little programs are starting up so slowly. I'm scared it's a problem with my computer or MinGW installation. When I start making more advanced programs, I don't want them running slower than they ought to be.
I find type casting to be very hard to grasp, I am not sure why. I understand how it works I suppose, but I find it hard to grasp why it would be needed in programming. So my question is, how often is type casting used in general programs? Is there an easier way I could be trying to teach myself about it? I am just using the tutorials provided by this site.
This is a problem I have been having with every program I write since I started using SDL 2. Whenever I compile my code and run my program, everything works perfectly fine until at some point (usually after 3-8 minutes of running), the program will stop responding completely and I will have to exit out of the console to close it. The code I believe is relevant is:
void MainLoop() { InitLoop(); while ( !QuitMain )
[Code].....
If I change SDL_PollEvent(&Event) to SDL_WaitEventTimeout(&Event,100), then the problem goes away (I did that and had the program running for about an hour without it stop responding before I decided that it solved the problem), so I believe that the problem has something to do with event handling. Also, it might be noteworthy to mention that when I use SDL_WaitEventTimeout with the second parameter being a small number (because 100 milliseconds is a long time to wait and makes the program run at like 8 FPS), the problem returns.
I have learned the basics you need to know about c++ so I was wondering, how do you make a GUI from scratch without using any programs like qt, daniweb, ect. Is there like a ongui() or something?
Is there any way to find the variables declared or defined in a c program and print those variables?? E.g. this is the code
#include<stdio.h> int main() { int a, b, c; printf("Enter two numbers to add"); scanf("%d%d",&a,&B)/>; c = a + b; printf("Sum of entered numbers = %d",c); return 0; }
I want to print all the variables been used. I used (gdb) info locals but its not giving the proper ouput.
I am using a windows application to start other processes. I am looking for a way to keep the form itself as the topmost program until it is closed, allowing the other programs enough load time.
I am currently trying to write a test program involving constructors. I know what I am about to ask is pretty basic stuff but Visual Studio is not recognizing when I declare strings for some reason. My code isn't completed yet but as I am typing string in to declare the variable in the class Visual Studio is not recognizing string as a usable value.
i saved it with name PIYUSHAN.cpp.after compiling above program, it shows no errors, that means it get compiled successfully. but when I try to run this program it shows Linker error :
Undefined symbol add(int,int) in module PIYUSHAN.CPP Linker error : Undefined symbol sub(int,int) in module PIYUSHAN.CPP Linker error : Undefined symbol mul(int,int) in module PIYUSHAN.CPP Linker error : Undefined symbol div(int,int) in module PIYUSHAN.CPP
So lately I've been writing multiple header and cpp files and I would always the same error when I finally #include headers in my main.cpp. This error
Code: undefined reference to `...`
On Youtube videos I see people doing this and their work magically compiles correctly. I found out that when I #include the headers' cpp files instead, my programs would compile. I use Code::Blocks with GNU GCC compiler.
I have started using code::blocks for practicing ,(was using bloodshed dev C++ til now). The thing is that m not able to compile multiple programs stored under a single project , as i have created project by the name of a topic and have decided to solve all problems related to that topic under that project.
When there was only one .cpp file in the project it compiled successfully ,but as soon as i created a second file and compiled it it says "main can be declared only once"
Recently I got a drawing tablet. One valued feature of this tablet is that it is pressure sensitive (2048 levels). No matter what the model, almost every company's tablet's features (like pressure) are compatible with well-known commercial products like Photoshop, and this is precisely what I'm wondering about:
If well-known graphic products can do it, how do I make my own program to recognize this device's features? How can I access/extract real-time data from a device. Assuming I have all driver stuff correctly installed.
I've been trying to google keywords like "[company] header files" or "[company] developing programs" or stuff like that to no avail... not really sure what to search for.
If you need specific information about the actual device, I will post it, but I'm also just looking for general knowledge about how to this type of thing, with any device.
(I'm not talking about a GUI or how to actually code graphics to respond to the pressure, just about receiving information from it.)