NO

Author Topic: POLINK: fatal error: Access is denied.  (Read 6965 times)

hotdone

  • Guest
POLINK: fatal error: Access is denied.
« on: August 25, 2010, 05:40:05 PM »
I compiled below codes then i got error called
Building for.exe.
POLINK: fatal error: Access is denied.
*** Error code: 1 ***
Done.

code i compiled is
#include<stdio.h>
int main()
{
FILE *fp;
char c;
fp=fopen("myfile.txt","r+");
if(fp!=NULL)
c=getc(fp);
while(c!=EOF)
{
printf("%c",c);
c=getc(fp);
}
fclose(fp);
return 0;
} ::)

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: POLINK: fatal error: Access is denied.
« Reply #1 on: August 25, 2010, 06:06:19 PM »
Which Windows version are you running on?

Where did you save your project to?
---
Stefan

Proud member of the UltraDefrag Development Team

Offline DMac

  • Member
  • *
  • Posts: 272
Re: POLINK: fatal error: Access is denied.
« Reply #2 on: August 25, 2010, 06:12:13 PM »
I sometimes get an error like this if I run code from the IDE and then edit the source and try to execute the code again.

Make sure that an instance of the console application is not already running before recompiling and testing it.
No one cares how much you know,
until they know how much you care.

CommonTater

  • Guest
Re: POLINK: fatal error: Access is denied.
« Reply #3 on: August 26, 2010, 07:39:26 PM »
I get that message a lot...
It's almost always because the program I'm working on is running.

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: POLINK: fatal error: Access is denied.
« Reply #4 on: August 27, 2010, 11:03:26 PM »
Cruel way to stop process.
Add this program to Tools menu with Arguments: $(TargetPath)
Code: [Select]
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <tlhelp32.h> // CreateToolhelp32Snapshot()

TCHAR szAppName[] = "ProcKill";

#pragma lib "psapi.lib"

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
{
HANDLE hSnapShot;
HANDLE hProcess;
PROCESSENTRY32 pEntry;
TCHAR szTmp[260];

if (!*lpszCmdLine) {
MessageBox(0, "Usage: ProcKill.exe <file>", szAppName, MB_OK);
return 1;
}

hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hSnapShot) {
pEntry.dwSize = sizeof(pEntry);
if (Process32First(hSnapShot, &pEntry)) {
do {
wsprintf(szTmp, "%d %s", pEntry.th32ProcessID, pEntry.szExeFile);
if (!lstrcmpi(pEntry.szExeFile, lpszCmdLine)) {
// found it
if (MessageBox(0, pEntry.szExeFile, szAppName, MB_OKCANCEL) == IDOK) {
hProcess = OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE, FALSE, pEntry.th32ProcessID);
if (hProcess) {
TerminateProcess(hProcess, 0);
CloseHandle(hProcess);
}
}
}
} while (Process32Next(hSnapShot, &pEntry));
}
CloseHandle(hSnapShot);
}
return 0;
}
This code try to close it first normally with WM_CLOSE
Code: [Select]
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <tlhelp32.h> // CreateToolhelp32Snapshot()

TCHAR szAppName[] = "ProcKill";

#pragma lib "psapi.lib"

BOOL CALLBACK TerminateAppEnum(HWND hwnd, LPARAM lParam);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
{
HANDLE hSnapShot;
HANDLE hProcess;
PROCESSENTRY32 pEntry;
TCHAR szTmp[260];

if (!*lpszCmdLine) {
MessageBox(0, "Usage: ProcKill.exe <file>", szAppName, MB_OK);
return 1;
}

hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hSnapShot) {
pEntry.dwSize = sizeof(pEntry);
if (Process32First(hSnapShot, &pEntry)) {
do {
wsprintf(szTmp, "%d %s", pEntry.th32ProcessID, pEntry.szExeFile);
if (!lstrcmpi(pEntry.szExeFile, lpszCmdLine)) {
// found it
if (MessageBox(0, pEntry.szExeFile, szAppName, MB_OKCANCEL) == IDOK) {
EnumWindows((WNDENUMPROC)TerminateAppEnum, (LPARAM) pEntry.th32ProcessID) ;
hProcess = OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE, FALSE, pEntry.th32ProcessID);
if (hProcess) {
if(WaitForSingleObject(hProcess, 1000)!=WAIT_OBJECT_0)
TerminateProcess(hProcess, 0);
CloseHandle(hProcess);
}
}
}
} while (Process32Next(hSnapShot, &pEntry));
}
CloseHandle(hSnapShot);
}
return 0;
}

BOOL CALLBACK TerminateAppEnum(HWND hwnd, LPARAM lParam)
{
DWORD dwID;

GetWindowThreadProcessId(hwnd, &dwID);
if (dwID == (DWORD)lParam) {
PostMessage(hwnd, WM_CLOSE, 0, 0);
}
return TRUE;
}
« Last Edit: August 28, 2010, 08:20:27 AM by timovjl »
May the source be with you

CommonTater

  • Guest
Re: POLINK: fatal error: Access is denied.
« Reply #5 on: August 28, 2010, 01:35:36 AM »
Or you could use FindWindow using the window title and sent it WM_Close


hotdone

  • Guest
Re: POLINK: fatal error: Access is denied.
« Reply #6 on: August 28, 2010, 03:08:15 PM »
Which Windows version are you running on?

Where did you save your project to?

i am using windows seven.. i saved it on desktop ...

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: POLINK: fatal error: Access is denied.
« Reply #7 on: August 28, 2010, 03:41:41 PM »
What is actually in this line:

Quote
Building for.exe

You can tick Verbose build from Project options... to see that polink.exe commandline.


May the source be with you