My code compiles and runs fine with MS VC++ 6.0 but when I compile and run with Borland, it crashes. Under vc++ 6 I was running winXP 32, with borland I am running vista 32bit.
It compiles with 0 errors and warnings but once it executes the below code I get a crash:
//DLL declare prototypes
extern "C" __declspec(dlle xport)RdmsrEx(D WORD, DWORD * , DWORD *, DWORD);
extern "C" __declspec(dlle xport)Initializ eOls();
extern "C" __declspec(dlle xport)GetDllSta tus();
The common error:
"...raised exception class EAccessViolatio n with message 'Access violation at address 019F3893. Write of address 0025170D. Process stopped. Use Step or Run to to continue"
[php]
//prototype
void GetTemps(DWORD* , DWORD);
//function
void GetTemps(DWORD* dwTemp, DWORD dwCoreNum)
{
DWORD dwEAX, dwEDX;
RdmsrEx( 0x19C , &dwEAX , &dwEDX , dwCoreNum );
dwEAX = dwEAX & 0xFF0000;
dwEAX = dwEAX >> 16;
*dwTemp = 95 - dwEAX;
}
//call to function
InitializeOls() ;
DWORD dwTemp;
DWORD dwAffinity = 1;
GetTemps(&dwTem p,dwAffinity);
[/php]
5 5656
This probably has to do with your use of windows libraries which are incompatible with the Borland compiler. My suggestion would be to forget about Borland altogether and get the latest VC++ for Vista. Otherwise, make sure you're using libraries that are compatible with both Borland and VC++.
The problem I posted above doesn't seem to stem from a function call where a library even comes into play. Another issue I had was my code freezing in a simple for-loop.
My C++ Builder 4 book says that C++ Builder is now nearly 100% ANSI compliant. So you are right about the code working.
There should be about the same incompatibiliti es using C++ Builder with external libraries as using the MinGW compiler (codblocks ide) with external libraries.
Are you linking the dll implicitly or explicitly?
My guess is that you are trying to implicitly link a dll in Borland C++ Builder that was built with Microsoft Visual C++. The .lib file accompanying the dll produced by msvc++ is specific to msvc++ (but don't quote me on that).
If the dll was generated outside of Borland C++ Builder, try linking explicitly by using LoadLibrary(); and GetProcAddress( ); to load the library and find the address of each function you are wishing to use...
My guess is that you are trying to implicitly link a dll in Borland C++ Builder that was built with Microsoft Visual C++. The .lib file accompanying the dll produced by msvc++ is specific to msvc++ (but don't quote me on that).
If the dll was generated outside of Borland C++ Builder, try linking explicitly by using LoadLibrary(); and GetProcAddress( ); to load the library and find the address of each function you are wishing to use...
I did use the above method (loadlibrary\ge tprocaddress) but I was unable to get it to work because the DLL was created in vc++. There was no lib file for the dll so I did the below to get it to work:
I built a def file with impdef, used an app that fixes each function call (adds _ infront of each function). And then I used implib on the created def file to create a lib file and then imported the lib file into my project. Using the above code the functions successfully get called. The function calling is taken care of.
However, if I try to call RdmsrEx twice in a row, the 2nd call throws an error. I also get errors on other lines of code if I put a for-loop in the same code block. I've never seen anything like this before in vc++.
I got it working. After looking it over I noticed this line didn't look right
*dwTemp = 95 - dwEAX;
I assigned "95 - dwEAX" to a temporary variable and then returned that temporary variable.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: NathanAllen |
last post by:
First of all to let you know I am using the following compiler:
Borland C++Builder 5.5.1 with Turbo Incremental Link 5.00
When I tried to make my first GUI drawing following Lawernceville Press's
book it created an error in the compliation process:
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
E:\Gui.cpp:
Warning W8004 E:\borland\Include\lvp\String.cpp 106: 'len' is assigned a
value that is never used in function...
|
by: Chris |
last post by:
I am just beginning programming again and need a bit of advice.
I have both Visual C++ 6.0 Standard Edition and Borland C++ Builder 6.
Of these two which do you consider the best for programming windows programs
(not the DOS style program). I have had a quick look at both of these and
Borland seems to have a lot more components (Buttons, Forms etc) than
Microsoft Visual C++. Does Visual C++ have these components easily
accesable.
Chris.
|
by: Christo |
last post by:
hey im a student about to start a course in c++ at uni, we have been told to
obtain a copy of borland c++ 5.01 (not c++ builder)
this is just a program with a compiler/linker and development environment.
it is simply called borland c++ 5.01
can anyone tell me where i can download either a free copy or a copy that
needs registering or someething, i can only find c++ builder which is
totally different from the program i have seen in...
|
by: Alex |
last post by:
I've a problem with following simple code (not really usefull):
//---------------------------------------------------------------------------
#pragma hdrstop
#include "stdio.h"
#include <iostream>
enum eTest1{et1_1, et1_2} e1;
enum eTest2{et2_1, et2_2} e2;
class ImageBase
{
|
by: shuusaku |
last post by:
Dear all,
I'm not sure this is the right place to ask for help, but I cannot find
any solution anywhere else, I hope you could help me.
I'm using Borland C++ Builder 6 with TeeChart v4.04 standard. I'm
writing a simple application that should acquire a signal from an
acquisition board, and diplay it on the screen. The signal is sampled
at 1000 hz, and I'm calculating its rms every 33 msec. Every time I
have a vector with ulCount (=33)...
| |
by: Morg |
last post by:
Hi,
I tried out #Develop and Borland C# Builder. I liked #Develop but it
was a bit buggy and failed alot :(
I really like Borland C# Builder however I cant find a way for it to
auto format my code with tabs when put curly braces, etc. Is there a
way to turn this feature on? It makes the code so much easier to read.
I know I can just manually tab myself but it would be nice if it was
automatic like #Develop is.
|
by: smartwolf agassi via DotNetMonster.com |
last post by:
I'm a C# language learner.
I want to know which IDE is better for C# programing, Borland C#Builder or
VS.net 2003?
--
Message posted via http://www.dotnetmonster.com
|
by: Cppbuildernoob |
last post by:
I need help on this:
- I supply code, specific for C++builder
- You will compile into single executeable installation file, with a
small bug into it.
- Must use C++builder 5.
- I will test compiled code, feedback trouble if any.
- If test oke, we will agree on a small fee, nothing spectaculair,
since the job aint that either.
- I will transfer fee
|
by: ZedLep |
last post by:
Hello,
First of all I'm a relatively inexperienced C++ programmer so this may seem a simple question to answer.
I'm trying to use zlib from www.zlib.net to decompress some data. However I run into an error when I try to compile the program :
E2015 Ambiguity between 'Byte' and 'System::Byte'
And the offending code (within zconf.h) is :
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |