|
I have a problem with the include files and I am getting an error :
win32.obj : error LNK2019: unresolved external symbol _BltAlpha referenced in function _DD_Init
This is how I have set up the project:
I call the BltAlpha in DD_Init in
win32.c:
#include "stdafx.h"
bool_t DD_Init(win* p)
{
BltAlpha(p,.....
I have declared all my include files in
stdafx.h:
#include "win32.h"
#include "blend.h"
And then I have included stdafx.h in both blend.c and blend.h
blend.c:
#include "stdafx.h"
// The implementation of BltAlpha:
int BltAlpha( win* p,int iDestX, int iDestY, LPRECT lprcSource, int iAlpha, DWORD dwMode )
{ ............
blend.h:
#include "stdafx.h"
//The declaration of BltAlpha:
int BltAlpha( win* p,int iDestX, int iDestY, LPRECT lprcSource, int iAlpha, DWORD dwMode );
So why am i getting this link error, I have really tried to put the header files in different combinations, but with no luck?!
Please is there anyone that can help me with this one before I´m going crazy!?
Thanks, Dani
|
|
|
|
|
Hi,
I think that this is a tricky question : try and rename your .c files into .cpp files, and it should solve the problem . Visual adapts the calling convention according to file extensions. You have probably created a C++ project, and tried to insert a c file. A very naive explanation would be: the way the parameters are called with
BltAlpha(p,.....
is the C++ way and the way you declare in in blend.c is compiled as the C calling convention. This is Ok for the compiler, but it cannot be linked.
If you do not want to rename your files, try modify the calling conventions in the settings of your project Project->Settings->C/C++->Category:Code Generation->Calling convention.
But I must admit, this is tricky
~RaGE();
|
|
|
|
|
As for the header file organisation, this should do it:
stdafx.h:
#include "win32.h"
#include "blend.h"
win32.c:
#include "stdafx.h"
blend.c:
#include "stdafx.h"
~RaGE();
|
|
|
|
|
Thanks Rage!!!!!!
Whooooooops! the blend.c was named blend.cpp in my project, did not noticed that !
This have to be a bug in Visual C++ 6.0, because the only options for adding a file is
new->c/c++ header file
or
new->c++ Source file and there is no option for a new c file
This is strange though, anyway thanks Rage
|
|
|
|
|
Dani100001 wrote:
This have to be a bug in Visual C++ 6.0, because the only options for adding a file is
new->c/c++ header file
I use Project --> Add To Project --> Files
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi,
I want to replace the hardcoded string by the path in %windir% in the following code
#ifdef WIN32
CHAR CFM_INI_FILE[CFM_NAME_LEN] = "C:\\Winnt\\abc.ini";
#else
CHAR CFM_INI_FILE[CFM_NAME_LEN] = "/Winnt/abc.ini";
#endif
can I do that?
I cannot use GetWindowsDirectory function because this code is in global space in a cpp file.
My understanding is a function can be called only from within a function and not from global space.
Please advice..
P.S. :- this code has to be in global space. If i put it in function and initialize there i have to make changes in over 60 files to make sure it is initialized before it is used.
|
|
|
|
|
It is possible to get the value of %windir% with several functions, amongst them
char *getenv( const char *varname );
but from what I understand in your msg, you do not want to use any initialisation, e.g. function call. So I am afraid that the answer to
venadder wrote:
can I do that?
is : yes, you can, but it will unfortunately not be replaced at runtime with "C:\Winnt".
So, be ready to modify your 60 files
~RaGE();
|
|
|
|
|
Hi,
Am sorry if the subject looks too long. Didn't know how to explain it better....
Here is my problem. I divide my SDI into 2 columns using dynamic splitter. I associate the left column with some view. Now i want the right column's view to show a dialog resource from one .dll. I could get the dialog resource from the .dll and display it in the right view by getting the resource ID from the dll ( after loading it ofcourse ) and then using the FindResource() and LoadResource(). But the problem is that if i enter something in the dialog resource and then click "Ok", then i expect my handler in the .dll to be called and then retrieve all the configuration parameters that user enters in the dialog resource.
But my handler is not getting called, and obviously because of that, the dll cannot get the parameters entered into the dialog resource.
Is there any way to do this? So that the .dll can contain the dialog resource, and i can embed it in my main exe after loading that dll. And then once user clicks ok on the dialog, the appropriate handlers and data exchange happens inside the .dll, and my main application neednot care about the configuration parameters that the .dll wants...
Thanks & Regards,
Kumar
Kumar
|
|
|
|
|
Hello
I would like to call ImpersonateLoggedOnUser to gain some extra rights for a particular task in my application. For the call I need an impersonation token. To get this I tried the LogonUser function, but I don't have enough privileges. Probably it's the SE_TCB_NAME privilege. If I inspect the results from GetTokenInformation it is true that I don't have that priv and hence cannot enable it.
Does anyone know how to get a proper impersonation token.
I've tried to call CreateProcessWithLogonW to create a dummy process as a different users, and with that process handle I can call OpenProcessToken to get a token to send to ImpersonateLoggedOnUser. This gives the expected result, but it is a verry uggly work around.
|
|
|
|
|
ahhhhhhhhh
H for H ello !
TOXCCT >>> GEII power
|
|
|
|
|
I think that
Per Nilsson wrote:
I tried the LogonUser function, but I don't have enough privileges
and
Per Nilsson wrote:
that process handle I can call OpenProcessToken to get a token to send to ImpersonateLoggedOnUser
are somehow contradictory. If the "different users" you are talking about has enough privileges to make a good token for ImpersonateLoggedOnUser , you should also be able to use it for
LogonUser and hence get the same sufficient privileges ... I think your call to LogonUser must have failed somewhere ...
~RaGE();
|
|
|
|
|
Consider the following-
DrawText (hdc, "Hello, Windows 95!", -1, &rect,
DT_SINGLELINE | DT_CENTER |DT_VCENTER) ;
Could someone show me some code that would draw each letter in a different color?
While I am grateful for any help you could offer, please just dont reply with something line "just use CDC::SetTextColor...". I know that. My problem is in how best to iterate through each character in the text and assign each letter a different color. I want to see A CODE FRAGMENT.
thanks again.....
|
|
|
|
|
again ?
a couple of questions ...
Do you know how to iterate through each character ?
Do you know how to compute the size/position of the text ( using CDC::DrawText )
another BIG hint : DT_CALCRECT ...
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Thanks for your answer. I know how to iterate. What I don't know is how to format the function call.
Example:
CString _str;
DrawText (hdc, "Hello, Windows 95!", -1, &rect,
DT_SINGLELINE | DT_CENTER |DT_VCENTER) ;
// Can I say something like
//call to iterator
{
DrawText (hdc, "_str[i]", -1, &rect,
DT_SINGLELINE | DT_CENTER |DT_VCENTER) ;
}
|
|
|
|
|
SkunkedWorks wrote:
// Can I say something like
//call to iterator
{
DrawText (hdc, "_str[i]", -1, &rect, DT_SINGLELINE | DT_CENTER |DT_VCENTER) ;
}
Only if you want _str[i] to show up on the DC.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
... for H uman being ?
TOXCCT >>> GEII power
|
|
|
|
|
I'm using the following to read a large text file ( 80+megs ); I need to read individual lines and eventually put them in a vector ( to be processed later )
ifstream file1
std::ifstream file1 ( sFileName.c_str() );
std::string oneString;
while (std::getline( file1, oneString ) )
{
}
this takes around 70 secs.
while using MFC
CStdioFile file( sFileName.c_str() , CFile::typeText|CFile::modeRead );
while (file.ReadString(s) )
{
}
takes around 10 seconds.
Is there a better way ? seems that reading with STL should not take that much more time than with MFC.
Is there a way to do it with some kind of inserter like ( this is very vague ... )
something = std::somefunction( filestream.begin(), filestream.end(), somefunctorToReadALine );
Thanks!!!
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
hi everyone...
i have this little problem i hope you can help me with.it's as follows:
i'm making a dll that contains a lot of functions..these functions work on both xp and 9x except for one function ((suppose it's fn1)) that works only on xp((this function uses SetLayeredWindowAttributes))...the problem is when building the dll with fn1 and then trying to use a not fn1 function on win9x an error message appears reporting that the dll is not found!!!!after building without fn1 the dll works properly...i want to be able to use the 9x supported function of the dll even if it's built with fn1...
note:there are no problems at all on winxp...
|
|
|
|
|
Change fn1() to explicitly load user32.lib via LoadLibrary() and use GetProcessAddress() for SetLayeredWindowAttributes() . Something like:
fn1()
{
HINSTANCE hLibrary = LoadLibrary("user32.dll");
if (NULL != hLibrary)
{
typedef BOOL (*SETLAYEREDWINDOWATTRIBUTES)(HWND, COLORREF, BYTE, DWORD);
SETLAYEREDWINDOWATTRIBUTES pSetLayeredWindowAttributes;
pSetLayeredWindowAttributes = (SETLAYEREDWINDOWATTRIBUTES) GetProcAddress(hLibrary, "SetLayeredWindowAttributes");
if (NULL != pSetLayeredWindowAttributes)
*(pSetLayeredWindowAttributes)(...);
FreeLibrary(hLibrary);
}
}
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
i think this idea works..but i think it's like working around the problem...it's like healing symptoms and forget about the disease...isn't there some better idea..
|
|
|
|
|
Actually, it's the preferred method for having a single DLL work on multiple platforms. You can always create multiple DLLs, one with the function and one without.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
the dynamic-loading way didn't work!!!i don't know why..
i get this error:
run-time check failure #0 - the value of ESP was not properly saved across a function call. this is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
note:the functions in the dll use _stdcall convention to be used with VB...
|
|
|
|
|
See if this article helps.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
This reminds me of MY current problem, where I need to put some functions in a DLL AND dynamically link to my own functions just to call two Microsoft APIs.
I need to know if there are instances of MSDE on a machine.
Using the 'preferred' functions NumInstalledInstances and IsInstanceNameValid.
These are in a static LIB file you link against. That's fine.
But, when you execute them, they need a DLL that is only installed if the machine ALREADY has one or more of their dependent MSDE DLLs.
So, if you want your EXE to load, you can't directly link with these functions, and so you put the functions in a DLL, but you can't statically link with your own DLL either, or you will still end up requiring the MSDE DLLs to load. So, you put the functions in your own DLL (which is statically linked to the Microsoft API), export some functions similar to the 'static' functions from the Microsoft API, and then DYNAMICALLY get the procedure address at runtime of your own two functions after dynamically loading your own DLL.
Yeeeeeehaw! Aint this fun!
|
|
|
|
|
i got a headache of that..i'm a newbee to these stuff so please give me some more details about what to link statically and what to link dynamically..
i'm using static linking between my c++ dll and APIs contained in it.and using the usual Declare statement in VB to call my dll's functions..what necessary steps i need to make to solve the problem..
note:the article suggests writnig something like:
typedef BOOL (* _stdcall fnptr) (HWND, COLORREF, BYTE, DWORD);
but this didn't work either..
|
|
|
|