|
Hi,
I have a problem regarding embedded dlls (managed and unmanaged).. Could you help me please ?
My problem is the following..
- my target is a Pocket PC
- I want to export an unmanaged dll that I've done using Embedded Visual C++ 4.0 and wrap it with a managed dll written in C++. My unmanaged class is :
header :
--------
#ifdef UNM
#define DLL_API __declspec(dllexport)
#else
#define DLL_API __declspec(dllimport)
#endif
class DLL_API DLLUnmanaged
{
public:
DLLUnmanaged();
DLLUnmanaged(const char * const);
~DLLUnmanaged();
const char * getstring() const {return str;}
char * suffix(int n);
private:
char * str;
unsigned short len;
};
cpp:
#include
#include "stdafx.h"
#pragma warning( disable : 4091 )
#include "UnmanagedDLL.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
DLLUnmanaged::DLLUnmanaged()
{
str = (char *)LocalAlloc(0, sizeof(char));
str[0] = '\0';
len = 0;
}
DLLUnmanaged::DLLUnmanaged(const char * const str0)
{
len = (unsigned short)strlen(str0);
str = (char *) LocalAlloc(0, sizeof(char)*(len+1));
for(unsigned short i = 0; i < len; i++)
str[i] = str0[i];
str[i] = '\0';
}
char * DLLUnmanaged::suffix(int pos)
{
unsigned short suffix_length;
pos--;
if (pos < 0) pos = 0;
suffix_length = len - pos + 1;
if (suffix_length > 0)
{
char * suff = new char[suffix_length];
for(unsigned short i = pos; i < len+1; i++)
suff[i - pos] = str[i];
return suff;
} else
return 0;
}
DLLUnmanaged::~DLLUnmanaged()
{
LocalFree(str);
len = 0;
}
- I want to use the managed extensions of Visual Studio .Net like this :
#using
using namespace System;
#include
using std::cout; using std::endl;
#include "path.../UnmanagedDLL.h"
public __gc class DLLManaged // to avoid using "DLLImport"s..
{
public:
String * find_suffix(String * s, int pos)
{
int length = s->Length;
char * in_string = new char[length+1];
for(unsigned short i = 0; i
{
in_string[i] = (char)s->Chars[i];
}
in_string[length] = '\0';
DLLUnmanaged * s0 = new DLLUnmanaged(in_string);
delete [ ] in_string;
return s0->suffix(pos);
}
};
... so here is what I've done when doing it only with Visual Studio .Net. I've added to the solution (that has got the unmanaged (I took "DLL MFC") and managed (I took ".Net DLL") ) a C# windows application that simply references the managed dll. All that works fine..
but if I want to make a project like this (actually the unmanaged dll that I use is a bit more complicated that the one I gave you) for a Pocket PC I encounter a lot of problems (please don't blame me, I'm a beginner!)
I tried to do it this way. The thing is that I don't know how to make an EMBEDDED MANAGED C++ DLL...
if I do the unmanaged project with Embedded Visual C++ 4, and if I make a .Net DLL similar to the one I've given to you upper, I get errors like:
ManagedDLL error LNK2020: jeton non résolu (0A000009) _CxxThrowException
ManagedDLL error LNK2020: jeton non résolu (0A00000B) delete
ManagedDLL fatal error LNK1120: 2 externes non résolus
(sorry, I've the French version of VS .Net)
obviously the linkage goes wrong..
So..what is the thing I've to do ? could you help me please, since I'm trying to fix the problem for many days now!
thanks to pay attention to it,
Julien (IT student)
|
|
|
|
|
Hi all,
Does anybody can tell me how to change the back ground color of the printable area of the print preview view. If I override the erase background method and set the background color then the area other than the printable area background is changed. I want to just change the printable area background.
thanx in advance
thanvir
|
|
|
|
|
This is done in the void CPreviewView::OnDraw(CDC* pDC) function which can be found in viewprev.cpp line 631.
You would have to replace the existing version of this function (probably by using your own class inheriting from CPreviewView). Take a look at my enhanced print preview articles which should get you going.
Roger Allen - Sonork 100.10016
Strong Sad: I am sad I am flying
Who is your favorite Strong?
|
|
|
|
|
Hi,
I encountered a problem in a project ,the realease version can not work properly while the debug version working well .
A cricheditctrl was created dynamically , I call the RequestResize() function in the onkeydown() for sending the EN_REQUESTRESIZE nofification message.
then I capture the EN_REQUESTRESIZE in onnotify() ,which is in the parent-window.
All above is for control the richedit control size freely.
the problem is this function can run smoothly in debug version , but not in release version!!!
who can help you , Thks ahead
Best Regards
Jun Mu
|
|
|
|
|
mujun wrote:
the problem is this function can run smoothly in debug version , but not in release version!!!
"Run smoothly", or lack thereof, is not a very specific description. What sort of problem are you seeing? Have you put in any sort of "debugging" code (e.g., message box, writing to a file) that tells you the state of things as the program is running?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
What I do is let the CRichEditCtrl can auto-resize itself according to the amount of the words it contains.
I mean this function can not work in release version. In release version, the Cricheditctrl keep a fixed width forever.
do you have any other ideas?
thks
Jun Mu
|
|
|
|
|
How to make a pause in the unfolding of a function ? I'd to make a pause of 1 second.
Thx
|
|
|
|
|
Sleep
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
hello
pls help me.i am a begginer. i tried a keyboard hook program for unicode.
using my program i can display unicdoe chacter in notepad. but it is not working in word or wordpad. part of my code is given .
LRESULT CALLBACK KeyProc( int nCode, WPARAM wParam, LPARAM lParam )
{
hwndw= GetFocus();
if (nCode < 0)
{
Sleep(0);
return CallNextHookEx(m_hHookKey, nCode, wParam, lParam);
}
Sleep(0);
if (nCode == HC_ACTION)
{
if (lParam & 0x80000000)
{
Sleep(0);
PostMessage(hwndw, WM_KEYUP, wParam, lParam);
}
BYTE ks[256];
GetKeyboardState(ks);
WORD w;
UINT scan;
int buff;
scan=0;
ToUnicode(wParam,scan,ks,&w,buff,0);
ch_u=TCHAR(w);
if(ch_u!=8)
{
PostMessage(hwndw,WM_KEYDOWN,8,0);
}
if(ch_u>=32 && ch_u<=126)
{
switch(ch_u)
{
case 'A':
ch=3347;
'
'
'
'
}
PostMessageW(hwndw,WM_CHAR,ch,0);
is there any way to change the character i have typed ,before reaching the destination window.
thanking you
arthi
|
|
|
|
|
Dear Friends,
I got a dialog window and i am displaying a small bitmap on the window. I placed a "picture control" on the dialog and give it the path of my resource bitmap. So far so good.
We all know that bitmap is square shaped and has some background. The background of my bitmap is of same color as that of the default color of Windows 2000's Window. As such my bitmap gives illusion of "Icon" because its background color is masked with the parent window color. I developed the application on Windows 2000 machine.
But the problem is when i run my application on Windows 98 or XP. The default window color on these Operating Systems is different than that of Windows 2000. So the background color of my bitmap becoms apparent. This looks very ugly. I want to give illusion of an Icon and not bitmap.
Can you tell me some appropriate solution ? One solution in my mind is to convert my bitmap into icon. But i don't know any tool that can do so. By Bitmap has some background and i want to completely remove that background and extract the remaining image as an icon. Is there any tool available that can help me ?
Imtiaz
|
|
|
|
|
Hi,
my proposal: ownerdraw
Load the bitmap and draw them to the area
take a look at the function (-link):
LoadImage()[^]
and the parameter LR_LOADTRANSPARENT
HTH
Frank
|
|
|
|
|
You can make parts of your Bitmap transparent.
You have to use an imagelist (CImageList I think)
Then you have to make a mask of your original bitmap with only TWO colors (eg. black and white) Then the black stuff is made transparant while the white stuff is visible.
Search on CBitmap, CImageList and stuff and you'll find it.
(I have done it once, but I can't remember the whole stuff)
Hope it helps
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimmy Hendrix
|
|
|
|
|
Rather than a bitmap, how about using an Icon. They have transparency already built-in and you can use either a static control or manual drawing.
onwards and upwards...
|
|
|
|
|
Hi,
I m trying to use InternetConnect() function to connect with FTP site...specifying valid USERNAME & PASSWORD but that always returns NULL, but when i test it using "anonymus" as USERNAME & PASSWORD it works fine.
But I want to login to the FTP using specific USERNAME & PASSWORD..
The sample snippet that is being successfull is :
HINTERNET hIntConnect = InternetConnect(hInet,"ftp.corsoft.net",INTERNET_DEFAULT_FTP_PORT,_T("anonymous"),_T("anonymous"),INTERNET_SERVICE_FTP,0,NULL);
And the code snippet that fails is :
HINTERNET hIntConnect = InternetConnect(hInet,"ftp.corsoft.net",INTERNET_DEFAULT_FTP_PORT,_T("UserName"),_T("Password"),INTERNET_SERVICE_FTP,0,NULL);
Does any one have idea then please reply me urgently. Or is there any other idea to login to the FTP site with specific USERNAME & PASSWORD.
Thanks in advance.
Chirag.
|
|
|
|
|
I can't spot any obvious error, attached is the code I use sucessfully, I know it works on 95, 98, NT and XP.
The obvious question is what is the error return? I have removed my error trapping so you can see the wood for the trees!
m_hInetSession = InternetOpen(_T("FtpUpload"),<br />
INTERNET_OPEN_TYPE_PRECONFIG,<br />
NULL,<br />
NULL,<br />
INTERNET_INVALID_PORT_NUMBER);<br />
<br />
DWORD dwFlag = m_bPASVMOde ? INTERNET_FLAG_PASSIVE : 0;<br />
<br />
m_hFTPConnect = InternetConnect(m_hInetSession,<br />
strURL,<br />
(INTERNET_PORT) m_nPort,<br />
strUser,<br />
strPWD,<br />
INTERNET_SERVICE_FTP,<br />
dwFlag,<br />
NULL);
"Laughing at our mistakes can lengthen our own life. Laughing at someone else's can shorten it."
- Cullen Hightower
|
|
|
|
|
Thanks a lot for reply.
The error return is ErrorCode : 12014 i.e. The request to connect and log on to an FTP server could not be completed because the supplied password is incorrect. Eventhough I am specifying correct password.
Regards,
Chirag.
|
|
|
|
|
You could try ravi's suggestion or my favourite use telnet and connect to port 21 then type
USER username
PASS mypassword
That way you can see what the server is sending
"Laughing at our mistakes can lengthen our own life. Laughing at someone else's can shorten it."
- Cullen Hightower
|
|
|
|
|
Hi, thanks for reply again.
I am now handling the situation in other way ... i.e. See my Code snippet below..
HINTERNET hIntConnect = InternetConnect(hInet,"ftp.corsoft.com",INTERNET_DEFAULT_FTP_PORT,NULL,NULL,INTERNET_SERVICE_FTP,0,NULL);
if (InternetSetOption(hIntConnect,INTERNET_OPTION_USERNAME,"UNIVERSE\\UserName",sizeof("UserName"))==FALSE)
int err=GetLastError();
if (InternetSetOption(hIntConnect,INTERNET_OPTION_PASSWORD,"Password",sizeof("Password"))==FALSE)
int err=GetLastError();
ret = FtpGetCurrentDirectory(hIntConnect,CurDir, &CurDirSize);
if (ret == FALSE)
int err=GetLastError();
ret = FtpSetCurrentDirectory(hIntConnect,"\kothi\cc");
if (ret == FALSE)
{
int err = GetLastError();
InternetGetLastResponseInfo(&nErr, sBuff, &nBuffLen);
}
The usually works fine except last action i.e. to Set the Current Working Directory. I am easily able to get the file from the root directory but not able to Set the Current working Directory.. The error i m getting id ErrorCode:12003.
Any Idea....that helps me a lot.
Thanks in advance.
Regards,
Chirag
|
|
|
|
|
Anonymous wrote:
ret = FtpSetCurrentDirectory(hIntConnect,"\kothi\cc");
shouldn't it be "/kothi/cc" or "./kothi/cc/" or "kothi/cc"? I can't remember off hand
Make sure you are really where you think you are before you try and change directories.
"Laughing at our mistakes can lengthen our own life. Laughing at someone else's can shorten it."
- Cullen Hightower
|
|
|
|
|
Anonymous wrote:
is there any other idea to login to the FTP site with specific USERNAME & PASSWORD.
You can specify the username and password as part of the URL - the format is "ftp://username :password @corsoft.net", where username is the username and password is the password.
You can verify this by opening an instance of Windows Explorer (not IE) and typing this in the address bar. You should see the file system on the FTP server. This is what I use as my FTP client.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
hello again,
I need to do 3 steps on a file, I've written 3 functions ( step1(),step2(),step3()), all of those steps requires the execution of ShellExecuteEx but I need them do be done sequentialy with mutual exclusion.
I've created a semaphore using CreateSemaphore but step2() starts before step1() finished. Here's the code
<br />
HANDLE hSemaphore=NULL;<br />
....
<br />
Semaphore=CreateSemaphore(NULL, 1, 1, NULL);<br />
if(Semaphore ==NULL)<br />
{<br />
MessageBox(hwndMain, "Unable to assure mutual execution,can't continue","MUTEX",MB_OK|MB_ICONERROR );<br />
break;<br />
}<br />
//into step1()
<br />
dwWaitResult=WaitForSingleObject(Semaphore,0L);<br />
switch(dwWaitResult)<br />
{<br />
case WAIT_OBJECT_0:<br />
if(ShellExecuteEx(&sei)== NULL)<br />
{<br />
ReleaseSemaphore (Semaphore,1, NULL);<br />
return false;<br />
}<br />
ReleaseSemaphore (Semaphore,1, NULL);<br />
return true;<br />
}<br />
//Into step2()
<br />
dwWaitResult=WaitForSingleObject(Semaphore,INFINITE);<br />
<br />
while (dwWaitResult==WAIT_TIMEOUT)<br />
{<br />
};<br />
If anyone can help me, that would be great, thanks!
Paolo
|
|
|
|
|
I take it you mean each step is running on its own thread?
Semaphores dont help you gaurentee order. All the do is protect say thread A accessing the same thing as thread B. Which order thread A and thread B run in is down to the scheduler. So it might happen A grabs the semaphore, B tries to and waits, A releases semaphore, B contnues to run. Or it might happen B grabs the semaphore, A tries to and waits, B releases semaphore, A contnues to run - its up to the scheduler (and of course your theads priority).
If you want things to happen one after the other, run them on the same thread:
void Foo(
{
Step1();
Step2();
Step3();
}
etc.
If you really want each step to happen on it's own thread, then you need to use events. Look up CreateEvent/SetEvent/ResetEvent
If I have the wrong end of the stick, and what you are asking is you want ShellExecuteEx not to return until the spawned process has finished, you do it like this.
SHELLEXECUTEINFO si;
si.fMask = SEE_MASK_NOCLOSEPROCESS;
si.etc etc
ShellExecuteEx(&si);
WaitForSingleObject(si.hProcess, INFINATE);
|
|
|
|
|
Hello!
please help me in this field.
when I run this program in visual C++ (6.0) this link error appears:
error LNK2001: unresolved external symbol _WMCreateEditor@4
Debug/main.exe : fatal error LNK1120: 1 unresolved externals
this program put marker on sound file
thank you for reply.
(I'm sorry.I could not speak English perfectly)
#######################################################
IWMMetadataEditor *pEdit = 0;
IWMHeaderInfo *pInfo = 0;
// Create the metadata editor object.
WMCreateEditor(&pEdit);
pEdit->Open(L"C:\\example.wmv");
pEdit->QueryInterface(IID_IWMHeaderInfo, reinterpret_cast<void**>(pInfo));
// Add the markers. Note that we add the last ones first. Do this when possible
// for improved performance when writing the markers to the file.
hr = pInfo->AddMarker(L"End", 520000000); // 52 sec.
hr = pInfo->AddMarker(L"Segue", 350000000); // 35 sec.
hr = pInfo->AddMarker(L"Intro", 15000000); // 1.5 sec.
// Commit changes and clean up.
pEdit->Flush();
pEdit->Close();
pInfo->Release();
pEdit->Release();
|
|
|
|
|
have you checked if all .lib files are included into the project? or check if prototypes of WMCreateEditor is declared correctly
Paolo
|
|
|
|
|
1. either link in the "wmvcore.lib" into your project settings (link tab)
or
2. add this to your source or into "stdafx.h"
#pragma commend(lib, "wmvcore.lib")
or
3. directly add the lib into your project as one of the files
|
|
|
|
|