Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Aug 25th, 2004, 8:42 PM   #1
vbtoosharp
Newbie
 
Join Date: Aug 2004
Posts: 5
Rep Power: 0 vbtoosharp is on a distinguished road
The DLL I have created uses a TTimer to update some variables. when I make a call to the DLL it returns the correct values only the first time its called after the first call it returns the same values. reason for them being the same values is that the TTimer is not refreshing the values. now this problem occures when i use the Delphi DLL with a C++ applcation. (for reason unknown this problem does not occure with VB.NET)

this is a problem i have had for a while know and still have no answer for. the link below is one to another fourm that shows some bikering between me and another person about this problem.

feel free to pitch in with some help.

example code, not the actual code I am having the problem with:


  library DelphiDLL;

  uses Windows, extctrls, SysUtils, Classes;

  //------------------------------------------------------------------------------

  type TTicker = class(TTimer)
  public
   Value: Integer;
   procedure Tick(Sender: TObject);
  end;

  procedure TTicker.Tick (Sender: TObject);
  begin
   Value := Value + 1;
  end;

  //------------------------------------------------------------------------------

  var g_ticker: TTicker;

  function GetClockValue(): Integer; export; stdcall;
  begin
   Result := g_ticker.Value;
  end;

  exports GetClockValue;

  begin
   g_ticker := TTicker.Create(nil);
   g_ticker.OnTimer := g_ticker.Tick;
   g_ticker.Value := 1;
   g_ticker.Interval := 100;
   g_ticker.Enabled := True;
  end.



c++ code


#include <windows.h>
#include <stdio.h>

 int main()
 {
  HINSTANCE lib = LoadLibrary("DelphiDLL\\DelphiDLL.dll");

  if (lib)
  {
   typedef int (__stdcall * ClockProc)();

   ClockProc GetClockValue = (ClockProc) GetProcAddress(lib, "GetClockValue");

   if (GetClockValue)
   {
    int time;
    do {
     time = GetClockValue();
     printf("%d\n", time);
    } while (time < 100);
   }

   FreeLibrary(lib);
  }

  return 0;
 }
vbtoosharp is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:47 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC