Click here to Skip to main content
15,889,116 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Visual C++ Prerequisites Pin
led mike10-Mar-08 9:20
led mike10-Mar-08 9:20 
GeneralRe: Visual C++ Prerequisites Pin
Maxwell Chen10-Mar-08 17:15
Maxwell Chen10-Mar-08 17:15 
GeneralRe: Visual C++ Prerequisites Pin
nike_arh10-Mar-08 9:08
nike_arh10-Mar-08 9:08 
GeneralRe: Visual C++ Prerequisites Pin
led mike10-Mar-08 9:14
led mike10-Mar-08 9:14 
GeneralRe: Visual C++ Prerequisites Pin
Nemanja Trifunovic10-Mar-08 10:00
Nemanja Trifunovic10-Mar-08 10:00 
QuestionPropertyGrid Attributes Pin
TheBerk10-Mar-08 8:04
TheBerk10-Mar-08 8:04 
GeneralRe: PropertyGrid Attributes Pin
led mike10-Mar-08 8:44
led mike10-Mar-08 8:44 
QuestionDefinition of dllimport function not allowed Pin
steve_rm10-Mar-08 7:16
steve_rm10-Mar-08 7:16 
Hello

I have downloaded this code from the internet and I am trying to compile it. Howerver, I keep getting these 2 errors which I cannot seem to solve.

Error C2491 StartNativeProcessing definition of dllimport function not allowed
Error C2491 StartNativeProcessingWithControlProc definition of dllimport function not allowed.

Many thanks for any assistance with this code.

Steve

// The following ifdef block is the standard way of creating macros which make exporting <br />
// from a DLL simpler. All files within this DLL are compiled with the NATIVEDLL_EXPORTS<br />
// symbol defined on the command line. this symbol should not be defined on any project<br />
// that uses this DLL. This way any other project whose source files include this file see <br />
// NATIVEDLL_API functions as being imported from a DLL, whereas this DLL sees symbols<br />
// defined with this macro as being exported.<br />
#ifdef NATIVEDLL_EXPORTS<br />
#define NATIVEDLL_API extern "C" __declspec(dllexport)<br />
#else<br />
#define NATIVEDLL_API __declspec(dllimport)<br />
#endif<br />
<br />
// ********************************************************<br />
// Callback function type definition for a function that is <br />
//  called when the processing performed by the native DLL<br />
//  is complete<br />
// <br />
// Function has no return value & no parameters.<br />
//  Example: void MyWorkCompleteFunction()<br />
typedef void (CALLBACK *NATIVEWORKCOMPLETEPROC)();<br />
<br />
// Callback function type definition for a function that is<br />
//  is called within each iteration of the native processing<br />
//  loop. Native processing will continue until the provided<br />
//  function returns 0;<br />
//<br />
// Function has BOOL return value (int in C#, Integer in VB.NET)<br />
// Function accepts an LPARAM as a parameter (IntPtr in .NET CF)<br />
//  The LPARAM parameter passes application defined data<br />
//  back to the application. The LPARAM is initially provided<br />
//  to the native DLL on the call to StartNativeProcessingWithControlProc<br />
//  function.<br />
typedef BOOL (CALLBACK *NATIVEWORKCONTROLPROC)(LPARAM lParam);<br />
// ********************************************************<br />
<br />
// Initiate processing on a background thread. When processing is complete,<br />
//  the workCompleteProc callback function is called<br />
NATIVEDLL_API void StartNativeProcessing(NATIVEWORKCOMPLETEPROC workCompleteProc);<br />
<br />
// Initiate processing on a background thread. On each iteration of the<br />
//  loop, the workControlProc function is called with the lParam passed<br />
//  as a parameter. The processing on the background thread continues<br />
//  until the workControlProc callback function returns 0. When processing <br />
//  is complete, the workCompleteProc callback function is called<br />
NATIVEDLL_API void StartNativeProcessingWithControlProc(<br />
	NATIVEWORKCONTROLPROC workControlProc, LPARAM lParam, NATIVEWORKCOMPLETEPROC workCompleteProc);<br />



// NativeDLL.cpp : Defines the entry point for the DLL application.<br />
//<br />
<br />
#include "stdafx.h"<br />
#include "NativeDLL.h"<br />
#include <windows.h><br />
#include <commctrl.h><br />
<br />
BOOL APIENTRY DllMain( HANDLE hModule, <br />
                       DWORD  ul_reason_for_call, <br />
                       LPVOID lpReserved<br />
					 )<br />
{<br />
	switch (ul_reason_for_call)<br />
	{<br />
	case DLL_PROCESS_ATTACH:<br />
	case DLL_THREAD_ATTACH:<br />
	case DLL_THREAD_DETACH:<br />
	case DLL_PROCESS_DETACH:<br />
		break;<br />
	}<br />
    return TRUE;<br />
}<br />
<br />
// The reference to the NATIVEWORKCOMPLETEPROC callback function<br />
NATIVEWORKCOMPLETEPROC g_workCompleteProc = NULL;<br />
NATIVEWORKCONTROLPROC g_workControlProc = NULL;<br />
<br />
// Sleep time to simulate work<br />
const int workSleepTimeInMilliseconds = 1500;<br />
<br />
// Forward declerations<br />
DWORD WINAPI ThreadFunc(void* pvThreadParam);<br />
void DoWork();<br />
<br />
// Initiate processing on a background thread. When processing is complete,<br />
//  the workCompleteProc callback function is called<br />
NATIVEDLL_API  void StartNativeProcessing(NATIVEWORKCOMPLETEPROC workCompleteProc)<br />
{<br />
	g_workCompleteProc = workCompleteProc;<br />
	g_workControlProc = NULL;<br />
<br />
	DWORD dwThreadId;<br />
	CreateThread(0, 0, ThreadFunc, NULL, 0, &dwThreadId);	<br />
}<br />
<br />
// Initiate processing on a background thread. On each iteration of the<br />
//  loop, the workControlProc function is called with the lParam passed<br />
//  as a parameter. The processing on the background thread continues<br />
//  until the workControlProc callback function returns 0. When processing <br />
//  is complete, the workCompleteProc callback function is called<br />
NATIVEDLL_API void StartNativeProcessingWithControlProc(<br />
	NATIVEWORKCONTROLPROC workControlProc, LPARAM lParam, NATIVEWORKCOMPLETEPROC workCompleteProc)<br />
{<br />
	g_workCompleteProc = workCompleteProc;<br />
	g_workControlProc = workControlProc;<br />
	<br />
	DWORD dwThreadId;<br />
	CreateThread(0, 0, ThreadFunc, (void*)lParam, 0, &dwThreadId);		<br />
}<br />
<br />
// Functioning running on background thread that simulates<br />
//  some sort of data processing. If only a NATIVEWORKCOMPLETEPROC<br />
//  callback function is provided, ThreadFunc will go through the loop once<br />
// If a NATIVEWORKCONTROLPROC callback function is provided, ThreadFunc will loop<br />
//  until the NATIVEWORKCONTROLPROC callback function returns 0<br />
DWORD WINAPI ThreadFunc(void* pvThreadParam)<br />
{<br />
	int loopControl = 0;<br />
<br />
	do<br />
	{<br />
		DoWork();<br />
		if (g_workControlProc != NULL)<br />
			loopControl = g_workControlProc((LPARAM)pvThreadParam);<br />
	}<br />
	while(loopControl != 0);<br />
<br />
	if (g_workCompleteProc != NULL)<br />
		g_workCompleteProc();<br />
<br />
	return 0;<br />
}<br />
<br />
// Simulate doing work for sleeping the specified period of time<br />
void DoWork()<br />
{<br />
	Sleep(workSleepTimeInMilliseconds);<br />
}

GeneralRe: Definition of dllimport function not allowed Pin
Mark Salsbery10-Mar-08 7:42
Mark Salsbery10-Mar-08 7:42 
GeneralRe: Definition of dllimport function not allowed Pin
Chris Losinger10-Mar-08 7:43
professionalChris Losinger10-Mar-08 7:43 
GeneralRe: Definition of dllimport function not allowed Pin
steve_rm10-Mar-08 16:00
steve_rm10-Mar-08 16:00 
GeneralRe: Definition of dllimport function not allowed Pin
Chris Losinger11-Mar-08 0:46
professionalChris Losinger11-Mar-08 0:46 
QuestionHow to simulate 'X' (the red button at the top right corner) ? Pin
Hanan88810-Mar-08 6:45
Hanan88810-Mar-08 6:45 
AnswerRe: How to simulate 'X' (the red button at the top right corner) ? Pin
Randor 10-Mar-08 7:02
professional Randor 10-Mar-08 7:02 
GeneralRe: How to simulate 'X' (the red button at the top right corner) ? Pin
Hanan88810-Mar-08 7:37
Hanan88810-Mar-08 7:37 
AnswerRe: How to simulate 'X' (the red button at the top right corner) ? Pin
Mark Salsbery10-Mar-08 7:07
Mark Salsbery10-Mar-08 7:07 
GeneralRe: How to simulate 'X' (the red button at the top right corner) ? Pin
Hanan88810-Mar-08 7:47
Hanan88810-Mar-08 7:47 
GeneralRe: How to simulate 'X' (the red button at the top right corner) ? Pin
Mark Salsbery10-Mar-08 7:54
Mark Salsbery10-Mar-08 7:54 
GeneralRe: How to simulate 'X' (the red button at the top right corner) ? Pin
Hanan88810-Mar-08 22:50
Hanan88810-Mar-08 22:50 
GeneralRe: How to simulate 'X' (the red button at the top right corner) ? Pin
Mark Salsbery11-Mar-08 6:18
Mark Salsbery11-Mar-08 6:18 
GeneralRe: How to simulate 'X' (the red button at the top right corner) ? Pin
ThatsAlok10-Mar-08 22:35
ThatsAlok10-Mar-08 22:35 
GeneralRe: How to simulate 'X' (the red button at the top right corner) ? Pin
Mark Salsbery11-Mar-08 6:19
Mark Salsbery11-Mar-08 6:19 
QuestionC++ graph library equivalent to MSAGL or GLEE? Pin
jwalsh10-Mar-08 6:33
jwalsh10-Mar-08 6:33 
QuestionRe: C++ graph library equivalent to MSAGL or GLEE? Pin
Maximilien10-Mar-08 7:11
Maximilien10-Mar-08 7:11 
QuestionRestricting others to inheritance from my class? Pin
Kishore JP10-Mar-08 5:34
Kishore JP10-Mar-08 5:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.