Home > Software engineering >  VB call write their own VC DLL, can't completely shut down
VB call write their own VC DLL, can't completely shut down

Time:10-05

I am a novice, has just started learning vb and gdiPlus, established a MFC library file, implementation using gdiPlus line drawing, call in vb program, but turn off after not exit completely, which has a task manager, should be a dynamic link library has a problem, consult everybody warrior is wrong,

This is a dynamic link library aaaaaaa. Nice method on the bottom of the CPP file, the key is
//aaaaaaa. CPP: defines the initialization routine of DLL, 
//

# include "stdafx. H"
# include "aaaaaaa. H"

# ifdef _DEBUG
# define new DEBUG_NEW
# endif

//
//TODO: if the DLL is relative to the MFC DLL dynamic link,
//is from now on any call DLL export
//function of the MFC AFX_MANAGE_STATE macro must be added to the
//this function, the front of the
//
//such as:
//
//extern "C" BOOL PASCAL EXPORT ExportedFunction ()
//{
//AFX_MANAGE_STATE (AfxGetStaticModuleState ());
////here for ordinary function body
//}
//
//this macro before any call MFC
//appear in each function is very important, which means that the
//it must be as the first statement in the function
//, even before all the object variable declarations,
//this is because their constructor can generate MFC
//DLL call,
//
//the other detailed information,
//please refer to the MFC technology shows 33 and 58,
//

//CaaaaaaaApp

BEGIN_MESSAGE_MAP (CaaaaaaaApp CWinApp)
END_MESSAGE_MAP ()


//CaaaaaaaApp structure

CaaaaaaaApp: : CaaaaaaaApp ()
{
//TODO: add code structure, here
//place all the important initialization in InitInstance
M_gdiplusToken=NULL;
}


//only a CaaaaaaaApp object

CaaaaaaaApp theApp;


//CaaaaaaaApp initialization

BOOL CaaaaaaaApp: : InitInstance ()
{
Gdiplus: : GdiplusStartupInput GdiplusStartupInput;
Gdiplus: : GdiplusStartup (& amp; M_gdiplusToken, & amp; GdiplusStartupInput, NULL);
CWinApp: : InitInstance ();

Return TRUE;
}

Int CaaaaaaaApp: : ExitInstance ()
{
//TODO: Add your specialized code here and/or call the base class
//unloading GdiPlus
If (m_gdiplusToken)
Gdiplus: : GdiplusShutdown (m_gdiplusToken);
Return CWinApp: : ExitInstance ();
}

Extern "C" long PASCAL EXPORT _stdcall nice (HDC HDC, long start, long end)
{
AFX_MANAGE_STATE (AfxGetStaticModuleState ());
//here for ordinary function body
Graphics Graphics (hDC);

Pen bluePen (Color (255, 0, 0, 255));
Pen redPen (Color (255, 255, 0, 0));

Int y=end;
For (int x=start; x <=end; X +=5)
{
Graphics. DrawLine (& amp; BluePen, start, y, x, start);
Graphics. DrawLine (& amp; RedPen, end, x, y, end);
Y=5;
}
return 0;
}

CodePudding user response:

The nice () function in Graphics, Pen didn't release!

CodePudding user response:

reference 1st floor Tiger_Zhao response:
nice () function in Graphics, Pen didn't release!

C + + leave scope automatically destructor,

Use End to End the program in VB,

CodePudding user response:

reference 1st floor Tiger_Zhao response:
nice () function in Graphics, Pen didn't release!

C + + Graphics and Pen not Dispose function, don't know how to release

CodePudding user response:

refer to the second floor zhao4zhong1 response:
Quote: refer to 1st floor Tiger_Zhao response:

The nice () function in Graphics, Pen didn't release!

C + + leave scope automatically destructor,

Use End to End in VB program,

Is this use?
 Private Sub Command1_Click () 
MoveToEx Me. HDC, 30, 30, P
LineTo Me. HDC, 150, 150,
Nice Picture1. HDC, 20, 300,
End
End Sub

Or not, the window can quit, but it still exists in the background, can't completely shut down, then vb6.0 by use card dead,,

CodePudding user response:

reference u012223553 reply: 3/f
Quote: refer to 1st floor Tiger_Zhao response:

The nice () function in Graphics, Pen didn't release!

C + + Graphics and Pen not Dispose function, don't know how to release

There is a ~ Graphics (); And ~ Pen (); Still have this problem, but after the call, close the window after the task manager shows still use memory

CodePudding user response:

ExitInstance () call?

CodePudding user response:

refer to 6th floor Tiger_Zhao response:
ExitInstance () call?

No this method, the c + + using gdiplus good pit

CodePudding user response:

 Private Sub Command1_Click () 
MoveToEx Me. HDC, 30, 30, P
LineTo Me. HDC, 150, 150,
Nice Picture1. HDC, 20, 300,
The Shell "taskkill/F/IM your program name. Exe/T", vbHide
End Sub

CodePudding user response:

The original poster is head live-action popeye?

CodePudding user response:

You are not a COM DLL, no one will be automatically calls InitInstance (), ExitInstance (),
You have to let the external call indirectly,
Really doubt CApp can such a definition in stdcall DLL call,
  •  Tags:  
  • API
  • Related