global variable in MFC Regular DLL -pls urgent

Hi,
I created a MFC Regular DLL and declare a variable
int __declspec( dllexport )  g_iVar= 4;

When i try to access these variable inthe application by importing g_iVar i
am getting the value of g_iVar as 0 not 4.

And i try to set the g_iVar to 10 in the application and try to access the
value inside dll exported function i am getting it a 4 and not 10.

Please help me out.

Reny


0
reny (27)
10/27/2003 8:01:44 AM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
351 Views

Similar Articles

[PageSpeed] 28

hi,
  Try setting the value of the g_iVar in the InitInstance() of the Dll 
and then use it.
As far as the second case wherein you set the value of the g_iVar to 10 
but the exported function of the dll reading it as a 4, check up if the 
value is being changed anywhere.
hth
gangadhar npk
Reny J Joseph Thuthikattu wrote:
> Hi,
> I created a MFC Regular DLL and declare a variable
> int __declspec( dllexport )  g_iVar= 4;
> 
> When i try to access these variable inthe application by importing g_iVar i
> am getting the value of g_iVar as 0 not 4.
> 
> And i try to set the g_iVar to 10 in the application and try to access the
> value inside dll exported function i am getting it a 4 and not 10.
> 
> Please help me out.
> 
> Reny
> 
> 


0
10/27/2003 8:13:03 AM
I repeat my earlier comment: I consider exporting a variable from a DLL to be exceedingly
poor programming methodology. Use an accessor function to read it. Also, although you are
showing how you export it, you have given no indication of how you import it; this makes
it hard to determine what has gone wrong.
					joe

On Mon, 27 Oct 2003 12:01:44 +0400, "Reny J Joseph Thuthikattu" <reny@bxtech.com> wrote:

>Hi,
>I created a MFC Regular DLL and declare a variable
>int __declspec( dllexport )  g_iVar= 4;
>
>When i try to access these variable inthe application by importing g_iVar i
>am getting the value of g_iVar as 0 not 4.
>
>And i try to set the g_iVar to 10 in the application and try to access the
>value inside dll exported function i am getting it a 4 and not 10.
>
>Please help me out.
>
>Reny
>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
10/27/2003 2:51:27 PM
Reply:

Similar Artilces:

MFC program to download a URL
Can someone send me a simple MFC program to download any URL -OR- at least point me to the library functions that I can use ? Thanks ThewhizKId thewhizkid wrote: > Can someone send me a simple MFC program to download any URL -OR- > at least point me to the library functions that I can use ? > > Thanks > ThewhizKId I am not sure what you mean by URL. If you mean getting a web page HTML then have a look at http://www.codeproject.com/internet/webgrab.asp otherwise choose what you need in the list http://www.codeproject.com/internet/ Simon. thewhizkid@rock.com (thewhizkid) ...

Passing Variables
In one of my 'form class objects (_afterupdate) I open a recordset. In another part of my form, I run a module (publc sub) for my main procedure. I would like to use some of the values from the recordset in my main module but am having trouble passing that value. Is this possible? Where do I need them defined or how? I have found a awful workaround but would like to do it the correct way. Any help (and proper syntax) would be great! Thank in advance. Can you post the VBA code so that we can see what you're doing? There are different ways this can be done: -- set a global, ...

Urgent!!! Is this possible
I have a spreadsheet with row 1 as my header allof the other rows i need exported to a file in the format below. This is critical and any help is greatly appreciated This is my spreadsheet layout. But there could be up to 8000 rows: c_last_name c_first_name c_middle_name c_userid Ables Donna F donna.ables Lovelace Eric eric.lovelace I need to export this to a file in this format. Each row needs to be enclosed in ( ) and each field in that row needs to be in " " with a comma ...

System.Xml in MFC
I tried to use System.Xml in MFC. Unfortunately, it turns out that all of System.Xml is set as COM-invisible. Therefore, my regasm gives me an empty type library. So my questions are: 1) Why was System.Xml marked as COM-invisible? 2) How do I go after using System.Xml in my MFC app anyways (some sample code would be great)? 3) What would the disadvantages/problems be using System.Xml in an MFC app although it was marked COM-invisible? Thanks >1) Why was System.Xml marked as COM-invisible? It's generally a good practice to mark an assembly non-visible to COM unless you fully test a...

Sinking MS Access form events from MFC console app
Hi All, I'm trying to sink MS Access form events using technique described in <<HOW TO: Handle Events for Excel by Using Visual C++ .NET (http://www.kbalertz.com/Q309301/Handle.Events.Excel.Using.Visual.aspx)>> Of course I did do all the needed code substitutions etc. All works rather well, I mean I'm getting to MS Access form IConnectionPointContainer etc. But the last code line - hr = m_pConnectionPoint->Advise(m_pAppEventListener,&m_dwConnectionCookie); doesn't work and returns hr = -2147220990. Here is MS Access form events interface ID I use: const II...

Is there a way to go through all the controls on a MFC dialog?
hi, I need to get through all the controls in a MFC dialog without knowing their ID at design time. That mean that the program must get the id and then get the control. Is there a better solution? One thing is for sure, I have to get the CWnd* of all of the controls on a dialog. How do I do this? thanks ThunderMusic > I need to get through all the controls in a MFC dialog without knowing > their ID at design time. CWnd* pChild = MyDialog.GetWindow(GW_CHILD); while (pChild) { // your code... pChild = pChild->GetWindow(GW_HWNDNEXT); } thanks, it works... I had the GetWin...

Bug: printing of a specific page range is broken in MFC-VS2005
If you create an MFC application that includes printing support, and your application does print-time pagination as described in this MSDN library topic: http://msdn2.microsoft.com/en-us/library/w7wzay73(VS.80).aspx then specifying printing of a specific range of pages in the print dialog does not work. The application always prints all pages of the document. To see this problem download and build the WordPad sample MFC application. Start a new blank document, then paste into it enough text to fill several pages. Choose Print from the File menu. Choose a print range of page 1 to page 1....

Another MFC extension DLL problem
I have an entry point defined like this: #ifndef BUILDING_UTILITY #define _UL_EXT_CLASS _declspec(dllimport) #else #define _UL_EXT_CLASS _declspec(dllexport) #endif void _UL_EXT_CLASS AttachToUtilityLib(LPCTSTR pszString) When I try to link the dll to another extension DLL, MyMessageBox is unresolved. If I take out the LPCTSTR parameter, it links fine. What could be wrong here? Maybe it's a name mangling issue, are this DLL's both C++ ? I assume you use different defines for your two DLL's otherwise you may have conlicts here. Cyrille Dupuydauby "David W. Simmo...

Outlook 2000
Aloha! I unfortunately, deleted a dll file on my computer. It happend when cleaning it up after a virus attack. Outlook 2000 is not installing again correctly. While attemtig it I get the error message: Failed to register a VB Script DLL. Reinstall or run Regsvr32.exe Vbscript.dll to self register. The key "DisplayName" is either missing or has an incorrect value. [File c:\Program Files\Microsoft Office\Office\Forms\1033\CNFRES.CFG, Section Description] The article which was to solve the issue is here. http://support.microsoft.com/?kbid=271141 I already followed the steps in it;...

show Global contact list in nav
We just switched over to exchange 2k3 and we have outlook clients. I want to know how to display the global address list(contacts) in the left nav pane along with the user's normal contacts. It's not appearing by default. The global address list is not the same as contacts. -- Ed Crowley MVP - Exchange "Protecting the world from PSTs and brick backups!" "Brett Michaels From Poison" <jms504@gmail.com> wrote in message news:1127420691.086686.73310@g47g2000cwa.googlegroups.com... > We just switched over to exchange 2k3 and we have outlook clients. > I ...

the future o MFC ?
I'm now learning MFC, and I'm curious if MFC is on the way out since the appearing o .NET framework ?! slash If i were you i would not bother learning MFC today. I beleive more in a combination of Pure win32 with some .net language using what is known as platform invoke. "slash" <slash@ms32.url.com.tw> wrote in message news:f42679b5.0410132351.3f86a6b0@posting.google.com... > I'm now learning MFC, and I'm curious if MFC is on the way out since > the appearing o .NET framework ?! > > slash slash wrote: > I'm now learning MFC, and I...

Handling renamed classes in MFC serialization
I would like to share some findings I made today. With the VERSIONABLE_SCHEMA facility it is possible to change object layout during the life of a product. You are still able to load old files stored using MFC's serialization mechanism when you prepare your Serialize member function accordingly. However, it is not easily possible to change the class name since the class name is stored in each archive. When opening old archives the old class name is not known to the new version of the application any more and the archive is not read in. You are locked to the old class names forever...

distribute mfc42.dll with the app?
My app crashes on win2003 server, but if it will work if I copy over an old mfc42.dll to my app directory. Is it a good idea to distribute mfc42.dll with my app? (I checked the mfc42.dll of Win XP against the one of Win2000, they seemed to be different.) Thanks. Wanjun It's OK to distribute this file, but you should localize it to your application directory so that it doesn't mess up any other applications that might get installed. You're right, there are a few versions with the same name on the DLL. Tom "Wanjun Yu" <wanjun_yu@hotmail.com> wrote in message ...

Using C# dll as COM in an MFC application
Hello, I have written a C# dll in VS2005. One interface and class are exported using Interop Services. I want to use this c# dll in my MFC application, using VS2003. It compiles after I imported the dll to my MFC app. On runtime I get class not registered HR error in my MFC project. I use the code as follow: _NewActivationPtr myActivation = NULL; HRESULT hr = myActivation.CreateInstance(__uuidof(NewSupernaActivation)); I don't what to do. Do I have to use GACUtil to register? If I want to use GACUtil do I have to sign my project? Trying do it had failed, because my third party librar...

URGENT: Run Time Error '429' in Store Operations Administrator
I'm constantly getting a run-time error 429 - ActiveX can't create object - when trying to run Store Operations Administrator on my back office PC. The Store Operations Manager also fails on the back office PC - can't connect to database -. The register (POS) is still functioning as is the server where the RMS database resides. How do I fix this? I've never seen Active-X errors from Administrator. I'd try uninstalling RMS on that system then reinstalling it. Also make sure you apply whatever service pack you're running on your other systems. Sometimes POS ...

slow global address book
I created a user account and found that it took 72 hours for the user to show up in the Global Address book. Is there anyway to have it show up instantly after creation? thank you for your help in advance Is this using Outlook 2003? If so, there are 2 main things at play because Outlook 2003 defaults to cached mode which uses the Offline Address Book (OAB): 1) When does your Offline Address List (OAL) get generated on the Exchange server? Check the properties of your Default Offline Address List. 2) When did Outlook last download the OAB? If the user was created prior to the last OAL...

Outlook 2003 & msvcr71.dll crash
Hello all, Recently I've been getting crashes from MIcrosoft Outlook 2003 when I close it down. Outlook works fine when it's open, it runs properly, but the moment I goto shut it down, I get an error asking me to submit the data to microsoft.. When I click the link to see the conents of the error/crash I get the following: AppName: outlook.exe AppVer: 11.0.6353.0 AppStamp: 408f2937 ModName: msvcr71.dll ModVer: 7.10.3052.4 ModStamp: 3e561eac fDebug: 0 Offset: 000017fb I have not installed any software around the time that this crash started happening. In fact my syste...

Variable Column Letter in formula....?
Hi, very new to this group (just signed up) and somewhat new to Excel. I am trying to see if there is a way to set up a variable for the column in a formula cell so that you can change the letter in one cell and it will change all of the formulas in the workbook that referenced the old lettered colum to the new lettered column. Example... I have a book that has Jan and Feb in column A and Column B respectively. In A2 I have 100 and in B2 I have 200. If I have a reference to A2 in cell C1 it should return a value of 100. What I am looking to do is in NEW cell d1, have a feild where I can t...

global address missing when sending word document as email attachment
Hi All, Im having trouble with my email, Im just wondering if you guys could help me... I use Outlook 2000 as my email browser. It started recently when you create a ms word document and go to: File - send to mail receipient or mail receipient as an attachement outlook does open ok except when I select the TO button I do not get my global address book (company address book), I get nothing. Any help I would really appreciate it. Thanks in advance... .. What do you show when you press the TO: button? Does the GAL appear in the dropdown list at all? What does show there? --� Milly ...

MFC painting order (Child then Parent)
Good night I have a CDialogBar with two CStatic that act as place holders for two CDialogs. On one of these dialogs I have a bunch of CStatics that act as holders for pictures. The idea behind this is that the user can drag and drop a pix from Dialog A to Dialog B and this picture gets drawn on the way through. In my CDialogBar based class I'm catching a event when the user drags this image from dlg A. The last position (CRect) of this pix should get invalidated and then this picture should be drawed onto the new location. Unfortunately, when I do that the picture gets drawn but th...

Problem with resources in MFC extension DLL
Hi, I have an MFC extension dll and in the destructor of one of the classes it exports I'm trying to access a string declared in its String Table, but I can't. It keeps loading an empty string. I'm guessing it's because the resources are unloaded before calling the destructor. Am I right? Thanks Mikel You have not explained what you are attempting to do. It seems that you are saying that the destructor is being called *from the main program* at some (undefined) point in time. Or is it being called from within the DLL itself? Also, it is not clear that the destructor, w...

dll hell: how to troubleshoot self-registration failure
I have a classic example of self-registering dlls for a 3rd party control (Crystal Reports 9 btw) that seem to install properly on every other machine out there but one XP SP1 machine. Of course this is an end users machine and there's only so much I can put them through over the phone to try to troubleshoot this. I think I read and followed the CR9 documentation fairly well etc. so I think I included all the files and supporting files the control claims to need and the fact that every other machine it works with fine. The only other theory I have is that something is missing or ...

CFrameWndEx in a splitter pane (MFC feature pack)
When I use a the new CFrameWndEx class as the frame in a pane in splitter window, the frame shows a title bar with rounded corners, and a little icon in the top left corner. This is not what I want - I'm just using it as a container to hold a toolbar and a view. If I use the older CFrameWnd class instead, the visual appearance is correct, but due to dependencies on the new MFC toolbar class, I want to use the new CFrameWndEx provided by the MFC feature pack. How do I make the CFrameWndEx not display a title bar in a splitter pane? Try deriving from CFrameWndEx and diddle the window st...

HOW TO FIX A VIEW GLOBALLY
lots of answers but none of them work.. here is the actual solution.. works like a charm.. http://techrepublic.com.com/5100-6270_11-5243615.html ...

Unable to load vpmsece.dll
Error msg received when starting Outlook 2000: Unable to load vpmsece.dll Path: c:\Program Files\NAVNT\vpmsece.dll OS: Windows 2000 Professional - all Service Releases and updates installed (OEM - so I don't have original installation disk) Running MS-Outlook Help/"Detect and Repair" does not fix. Does not appear to impact application operation. Mainly an aggravation I'd like to eliminate. Any assistance to repair this problem would be appreciated. ...