Passing data out of a dll

Hi all...


I have a dll that needs to pass on some data back to the main program.
But I'm not entirely sure how I can accomplish this and still keep the
dll free from unnecessary dependencies.

I thought of defining a struct inside the dll, and passing back a 
pointer to it (after the dll filled it up)... but then the main 
program would need to be made aware of the struct definition too.
So then I thought of moving the struct definition into a separate 
header file and including that in both the main program and the dll. 
This, although solves the initial problem, would create an indirect 
dependency (the dll gets bound to the main program via the header).

Would anyone care to share his/her thoughts on the issue? How can I
make the dll truely independent and still be able to exchange
information with the rest of the program?


Thank you for you time
Adeel



PS. One solution could be using the primitive data types for the
exchange but I'm sure you guys can think out a better one. 


0
Adeel
4/30/2006 10:08:41 AM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
192 Views

Similar Articles

[PageSpeed] 45

> but then the main
> program would need to be made aware of the struct definition too.

Yes. You can do this by exporting the class from the DLL. The class can
reside in a any module and can be passed between modules. Module where
this class is declared/defined will need to export it. Other modules
which  need to use this class will need the header file and will import
it. 


---
Ajay

0
4/30/2006 2:32:36 PM
Thanks Ajay.

Do you mean to say that if I export my struct declaration in the dll, 
it will be visible in the main program as well...?? That is, will just 
doing the LoadLibrary(...) in the main program make it visible there?


The other thing I learned from your response was that my question was 
rooted in deep lack of knowledge (Oh look at that!! before this I 
never knew lack of knowledge could be deep) of dll programming.


Thanks again
Adeel. 


0
Adeel
4/30/2006 5:20:33 PM
> Do you mean to say that if I export my struct declaration in the dll,
> it will be visible in the main program as well...??

If you export your class in one module, other modules will be able to import
it. You can use this class in any module as if it was declared/defined in
that particular module. For DLLs etc, this will be helpful:

http://www.codeguru.com/Cpp/W-P/dll/
http://www.flipcode.com/tutorials/tut_dll01.shtml
http://msdn2.microsoft.com/en-us/library/a90k134d(VS.80).aspx
http://msdn2.microsoft.com/en-us/library/8fskxacy.aspx

--
Ajay Kalra [MVP - VC++]
ajaykalra@yahoo.com




0
ajaykalra (6840)
4/30/2006 7:06:09 PM
Thanks again Ajay... that was quite helpful.

Cheers
Adeel 


0
Adeel
4/30/2006 8:12:17 PM
Reply:

Similar Artilces:

Is It Possible To Pass Parameters to A Pass Through Query
My assumption is that's it's not. At work I use ODBC to connect to our oracle database with Access 2003. There are cases where using a pass through query runs much much faster and I then use it in a make table query to make a local table. In access you can use brackets [] to have it ask for input. May I assume there is no way to do anything like that in a pass through query? Create a PassThrough query and use code to assign the SQL to this query filtering it with a parameter, and then run it e.g Dim MyVariable As Integer MyVariable = InputBox("Please select a Number&quo...

pack money data?
Is it possible to pack and/or otherwise clean up Money's data file? I'm sure I don't have 12MB of data in that file, despite its size. It's probably a jumble in there, just waiting for a chance to get corrupted. In microsoft.public.money, Paul Pedersen wrote: >Is it possible to pack and/or otherwise clean up Money's data file? I'm sure >I don't have 12MB of data in that file, despite its size. It's probably a >jumble in there, just waiting for a chance to get corrupted. > 12 MB is below average I suspect. I recommend you minimize getting s...

Pass multiple selected values from list box to table
How do I pass multiple selected values from a list box to a table? I've found code to use the values as criteria in a query but would now like to store the values in a table (at least temporarily) thanks in advance. jack Pass selected values from a list box to a table? I don't really think you want to do this. Can you describe more about what you are trying to accomplish? You just store raw data in a table. You don't store manipulated data in a table. Maybe you need a query to do what you want to do... -- Ryan--- If this information was helpful, please indi...

accessing data from another document or tab
Is there any way to run functions with a range from a seperate page o tab in the same document -- Message posted from http://www.ExcelForum.com Hi sure. e.g. =SUM('othersheetname'!A1:A100) Just enter the foormula name and select the range with your mouse (also on a different worksheet) -- Regards Frank Kabel Frankfurt, Germany > Is there any way to run functions with a range from a seperate page or > tab in the same document? > > > --- > Message posted from http://www.ExcelForum.com/ ...

Lookup Wizard changing Data Type
I am trying to make Lookups from Table Field to Table Field and generally it seems OK. However the LookupWizard is changing the Data Type from Text to Number (I guess it's looking at the ID?) Data picked from Combo Box 'looks' OK in Table view A Query view is asking for a number but displays the Text field value when a valid ID number is added. Viewing Results in FrontPage Database Wizard, and using hand coded .asp querie, it's showing the ID field value. I can see why... Any ideas? Merci. Yes, the wizard isn't the problem it's the use of Lookup Fields in ...

How do I sum numbers based on other data
I have a spreadsheet with several thousand entries. On one sheet, call it sheet 1, there is One column with about 100 names, another column has number amounts. My other sheet, call it sheet 2, has a list of names. What I would like to do is for each name on sheet 2, sum up the number values from sheet one for that particular name. So the end result would be a column on sheet two that shows the totals taken from sheet 1 for each name. I keep adding new entries on sheet one, so the totals on sheet 2 must always show the updated totals. Any help would be greatly appreciated. I am...

How to pass an object from C++
Hello! We have a C# asp.net web application that is using a COM dll We use the tlbimp to be able to use the COM dll from C# asp.net web application The method InitRules shown below is located in the COM dll. It can be seen below the text Original. Method InitRules below is called from C# but we want to pass an object of type Handle_DS in addition to all the other parameters. You can see the modified InitRules below marked Modified Note the object of type Handle_DS is a C++ object that is created from C# asp.net application and pass into the InitRules I have also copied the whole idl fil...

help!! mshtml.dll exception
Hi All, My application is loading multiple Dhtml files on multiple screens using LoadFromResource() command. And intermittently there is a Mshtml.dll exception message pop up with the following information: ModVer: 6.0.2800.1106 Offset: 000dfd47 My IE exploer version is 6.0.2900.2180.xpsp_sp2_rtm.040803-2158. Could someone please tell me what are the possible causes of error. Thanks Joe ...

Importing Data from Access into Excel
I have a spreadsheet that has mutiple tabs that I want to import data from an Access table into a specific cell everytime I refresh. That's not a lot of information to go on, but....in general, you could start with: 1)Select the cell where the data pull will begin to store the Access data 2)Data>Import External Data>New database Query 3)Select the MS Access data source 4)Select the table(s) you need to use and progress through the MS Query screens. 5)At the end, you can either select to edit the query or just send the data back to Excel. 6)Repeat for each sheet that is to re...

use data on excel sheet to input data on web page
I don't know if you can do this but here's the question. I would like to take some data on a spread sheet (example: division # and item code) and have this placed on a web page in the correct spots (division is a drop down box) so the site will find the correct information and then have excel import the found data onto a separate work sheet. Any insight into this would be very helpful. ...

Why does linked data from blank cells become a zero?
When linking data within the same workbook (to different tabs) any cell that is empty - shows up in the new tab as a ZERO (0).....what am I doing wrong? I want those cells to remain blank. That's just the way it is .. Instead of : =Sheet2!A1 you could use an error trap: =IF(Sheet2!A1="","",Sheet2!A1) Alternatively, we could suppress the display of extraneous zeros in the entire sheet via: Click Tools > Options > View tab > Uncheck "Zero values" > OK -- Rgds Max xl 97 --- GMT+8, 1� 22' N 103� 45' E xdemechanik <at>yahoo<dot&g...

Downloading data into Excel
I am interested in purchasing business leads from several different companies. These leads would contain name, address, phone, etc. The autoresponder system I would like to use accepts data from Excel. I would like to know what data format leads can I use that could be downloaded into Excel. Also, since I am familiar with computers and Excel but not an expert, I would like to get information on EXACTLY how to download the data from the acceptable formats into Excel. Any help you folks can provide would be greatly appreciated. Thanks in advance! healthplanman@aol.com ...

Outlook 2003 data recovery other than .pst/.ost
HI Guys, Recently my old PC got crashed & now I am trying to transfer all the relevant data to new m/c but I am not able to recover emails from the outlook 2003. As I dont see any .pst/.ost files on that m/c. Is there any other format those emails would be stored ? How do I restore it on my new pc. Thanks for your help Venkat In news:1130383029.526144.269300@o13g2000cwo.googlegroups.com, venkat <venkatakrishnabr@gmail.com> typed: > HI Guys, > > Recently my old PC got crashed & now I am trying to transfer all the > relevant data to new m/c but I am not able to re...

Data moving 2
I have following code: Sub climate() Dim x As Long, y As Long x = Range("X" & Rows.Count).End(xlUp).Row y = InputBox("enter the row number to paste") Range("A2:BK2" & x).Copy Range("A" & y).PasteSpecial MsgBox "Updated" End Sub I want to cut data of range(A2:BK2 to end row related) and then paste to row number which determine in Box. when i run above code on some of sheets, error message appear(Run Time error 1004). please note that, this code with cut command not run, only with copy command. any help will be gre...

Summing a years worth of data
Hi If data is entered every month in one tab. How would i then sum thi data by year into another tab? if necessary i dont want to kee changing the formula from year to year eg Col A Col B Jan 04 20 Feb 04 25 Then another tab that sums data by year eg col A Col -- Message posted from http://www.ExcelForum.com Hi if column A on your second sheet contains the year try the following in B1 =SUMPRODUCT(--(YEAR('sheet1'!A1:A1000)=A1),'sheet1'!B1:B1000) -- Regards Frank Kabel Frankfurt, Germany "david72 >" <<david72.149hr...

File MSVCR80.dll not found
Just tried to run a trial copy of Outlook 2007 that came with my Shadow phone. It appeared to install Ok, but when I tried to run it received the message "This application failed to start because file MSVCR80.dll was not found". What is problem and where can I get this file. Are you using Norton as an Anti Virus for your Outlook ?=20 --=20 Peter Please Reply to Newsgroup for the benefit of others Requests for assistance by email can not and will not be acknowledged. "T&V Seitz" <tvs-fl@cfl.rr.com> wrote in message = news:eNYtFXBQIHA.5160@TK2MSFTNGP05.ph...

100% Passing Guaranteed in All I.T. Exams/Certifications at 1st Attempt Hi Friends, To pass all types of I.T Exams/Certifications with mind blowing results in 1st attempt just visit http://www.itreal
100% Passing Guaranteed in All I.T. Exams/Certifications at 1st Attempt Hi Friends, To pass all types of I.T Exams/Certifications with mind blowing results in 1st attempt just visit http://www.itrealexams.com/ and get real time Q&As, Brain Dumps, Real Exams, Study material, E-Books, Video Exams and Labs for your all type of I.T Certification Exams. ...

Charting more than 255 bits of data
Is there a way to chart more than 255 bits of data; which is Excel's limit? If yes, is there a limit to that amount of data? Thanks. That's the limit to the number of series in a chart. Each series can hold up to 32000 points, subject to a maximum of 256000 points in the chart. I suspect you have 255 series each with one point. Could you select the data all at once and make a single series with 255 points? - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions Peltier Technical Services, Inc. - http://PeltierTech.com _______ "PVakerling" <PVa...

Data Access Page
I am quite a novice with Access, but I have managed to create a basic database. Previously when entering reference numbers on a data access page, when I used "tab", the rest of the corresponding information would show up. For whatever reason, I can now only see this information when I "save". I haven't a clue what I have pressed or unticked. Can anybody help me please? Cath ...

blank data field shows quote in formula, how to delete it?
In a data file I just received, many blank fields show a single-quotation mark in the formula. The <<if>> statement does not recognize these fields as blank. I have tried to 'find and replace' the marks using a search for <<'>> and also for <<~'>> both without success. How can I fix these fields, in bulk, so they behave like blanks? try =if(or(a1="",a1=" "),1,2) -- Don Guillett SalesAid Software donaldb@281.com "wdanner" <wdanner@discussions.microsoft.com> wrote in message news:4084C819-F2FF-4E8...

exporting data to access #2
Dear all, I'm trying to export data from excel to access, but I'm having some difficult: The layout of my sheet is the following: A B C D E F 1 2 3 3* 4 5 6 0701 0702 0703 0704** 7 10*** salary 100 101 102 103 8 20 others 50 51 52 53**** *profi_center_code ** periods *** accounting_code **** values Layout of the table in access: automatic numbering / accounting_code / profi...

Passing arguments to procedures
There is something fundamental that I have failed to grasp about passing arguments to procedures. I have a form featuring a set of unbound controls displaying dates and the corresponding days of the week. (For some reason, the long-date format, on my computer, does not include the latter, as the documentation suggests it might, so it has to be separately calculated and displayed.) A default date is displayed in each control, on Form_Open. This can then be manually adjusted by a pair of ‘up’ and ‘down’ buttons associated with each day/date control pair. In the case of the control ‘St...

IT CertificationzzzZ.....100% GUARANTEED PASS.......!!!@!!!
IT CertificationzzzZ.....100% GUARANTEED PASS.......!!!@!!! Hi guys, If you are serious about your professional career and pass IT Certification exam in first attempt then Visit http://www.FreeExamKing.com and get latest Questions And Answers Dumps for Microsoft, Oracle, Cisco, CompTIA and many more, i have used and found it very helpful. ...

Other data bases?
Hello! I am a Vba/Excel fanatic and have made several succesful applications. I was wondering, however, how can I use VBA with other data bases such as MySQL? What is the procedure for migrating to other data bases? Could you give me some advice for using a succesful application with a database that is about to reach the 65536 row limit? I thank you in advance, Albert Why don't you store the data in a MySQL database, and use Excel to query data using ADO. Your SQL can select the records you need, or even summarise it. -- HTH Bob Phillips (replace somewhere in email address with g...

Moving data from personal folders to exchange folders
Hi, My company is migrating over to use Microsoft exchange. I have it working on my system but the problem is that in Outlook new folders are created on the exchange server for inbox, calender, tasks, etc. The Outlook shortcut bar points to the new folders. So How do I move the data from my old folders to the new folders on the exchange server? For instance how do I move all of my Calender data from my calender under personal folders to the new calender which shows up in outlook under "Outlook Today [mailbox]"? Any help would be appreciated. Dave ...