Solved

Access violation

Posted on 2003-11-02
3
1,794 Views
Last Modified: 2012-05-04
I have a global CRITICAL_SECTION object, but when I try to use EnterCriticalSection() with it, I get an access violation.

CRITICAL_SECTION g_criticalSection;
...

//Then later on in a global function I have
EnterCriticalSection(&g_criticalSection);  // Access violation here
memset(g_szClipboard,0,sizeof(g_szClipboard));
LeaveCriticalSection(&g_criticalSection);

What could be the problem?
0
Comment
Question by:lwinkenb
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 9666663
Have you used

InitializeCriticalSection (  g_criticalSection);

before using it? If not, this would explain the problem...
0
 
LVL 5

Author Comment

by:lwinkenb
ID: 9666683
argh, I knew it was something simple.
Thanks jkr.
0
 
LVL 86

Expert Comment

by:jkr
ID: 9666693
You're most welcome :o)
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question